Improve API

This commit is contained in:
schmelczerandras 2020-09-16 11:31:26 +02:00
commit 78444d8cc6

View file

@ -1,21 +1,19 @@
import { waitWhileFalse } from '../../../helper/wait-while-false';
import { tryEnableExtension } from '../helper/enable-extension';
import { checkProgram } from './check-program';
import { createShader } from './create-shader';
export const createProgram = async (
export const createProgram = (
gl: WebGL2RenderingContext,
vertexShaderSource: string,
fragmentShaderSource: string,
substitutions: { [name: string]: string }
): Promise<WebGLProgram> => {
): WebGLProgram => {
const program = gl.createProgram();
if (!program) {
throw new Error('Could not create program');
}
const extension = tryEnableExtension(gl, 'KHR_parallel_shader_compile');
// const extension = tryEnableExtension(gl, 'KHR_parallel_shader_compile');
const vertexShader = createShader(
gl,
@ -31,16 +29,17 @@ export const createProgram = async (
fragmentShaderSource,
substitutions
);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);
if (extension) {
/*if (extension) {
const checkCompileStatus = () =>
gl.getProgramParameter(program, extension.COMPLETION_STATUS_KHR);
await waitWhileFalse(checkCompileStatus);
}
}*/
checkProgram(gl, program);