twgl.js 4.22.1 → 4.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /* @license twgl.js 4.22.1 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
1
+ /* @license twgl.js 4.23.0 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
2
2
  Available via the MIT license.
3
3
  see: http://github.com/greggman/twgl.js for details */
4
4
  /*
@@ -548,6 +548,15 @@ function negate$1(m, dst) {
548
548
  return dst;
549
549
  }
550
550
 
551
+ /**
552
+ * Creates a matrix.
553
+ * @return {module:twgl/m4.Mat4} A new matrix.
554
+ * @memberOf module:twgl/m4
555
+ */
556
+ function create$1() {
557
+ return new MatType(16).fill(0);
558
+ }
559
+
551
560
  /**
552
561
  * Copies a matrix.
553
562
  * @param {module:twgl/m4.Mat4} m The matrix.
@@ -1717,6 +1726,7 @@ var m4 = /*#__PURE__*/Object.freeze({
1717
1726
  axisRotate: axisRotate,
1718
1727
  axisRotation: axisRotation,
1719
1728
  copy: copy$1,
1729
+ create: create$1,
1720
1730
  frustum: frustum,
1721
1731
  getAxis: getAxis,
1722
1732
  getTranslation: getTranslation,
@@ -7243,56 +7253,79 @@ function addLineNumbersWithError(src, log = '', lineOffset = 0) {
7243
7253
  * @memberOf module:twgl
7244
7254
  */
7245
7255
 
7256
+ /**
7257
+ * Program Callback
7258
+ * @callback ProgramCallback
7259
+ * @param {string} [err] error message, falsy if no error
7260
+ * @param {WebGLProgram|module:twgl.ProgramInfo} [result] the program or programInfo
7261
+ */
7262
+
7246
7263
  const spaceRE = /^[ \t]*\n/;
7247
7264
 
7265
+ /**
7266
+ * Remove the first end of line because WebGL 2.0 requires
7267
+ * #version 300 es
7268
+ * as the first line. No whitespace allowed before that line
7269
+ * so
7270
+ *
7271
+ * <script>
7272
+ * #version 300 es
7273
+ * </script>
7274
+ *
7275
+ * Has one line before it which is invalid according to GLSL ES 3.00
7276
+ *
7277
+ * @param {string} shaderSource The source of the shader
7278
+ * @returns {{shaderSource: string, lineOffset: number}}
7279
+ */
7280
+ function prepShaderSource(shaderSource) {
7281
+ let lineOffset = 0;
7282
+ if (spaceRE.test(shaderSource)) {
7283
+ lineOffset = 1;
7284
+ shaderSource = shaderSource.replace(spaceRE, '');
7285
+ }
7286
+ return {lineOffset, shaderSource};
7287
+ }
7288
+
7248
7289
  /**
7249
7290
  * Loads a shader.
7250
7291
  * @param {WebGLRenderingContext} gl The WebGLRenderingContext to use.
7251
7292
  * @param {string} shaderSource The shader source.
7252
7293
  * @param {number} shaderType The type of shader.
7253
- * @param {module:twgl.ErrorCallback} opt_errorCallback callback for errors.
7254
7294
  * @return {WebGLShader} The created shader.
7255
7295
  * @private
7256
7296
  */
7257
- function loadShader(gl, shaderSource, shaderType, opt_errorCallback) {
7258
- const errFn = opt_errorCallback || error$1;
7297
+ function loadShader(gl, shaderSource, shaderType) {
7259
7298
  // Create the shader object
7260
7299
  const shader = gl.createShader(shaderType);
7261
7300
 
7262
- // Remove the first end of line because WebGL 2.0 requires
7263
- // #version 300 es
7264
- // as the first line. No whitespace allowed before that line
7265
- // so
7266
- //
7267
- // <script>
7268
- // #version 300 es
7269
- // </script>
7270
- //
7271
- // Has one line before it which is invalid according to GLSL ES 3.00
7272
- //
7273
- let lineOffset = 0;
7274
- if (spaceRE.test(shaderSource)) {
7275
- lineOffset = 1;
7276
- shaderSource = shaderSource.replace(spaceRE, '');
7277
- }
7278
-
7279
7301
  // Load the shader source
7280
- gl.shaderSource(shader, shaderSource);
7302
+ gl.shaderSource(shader, prepShaderSource(shaderSource).shaderSource);
7281
7303
 
7282
7304
  // Compile the shader
7283
7305
  gl.compileShader(shader);
7284
7306
 
7307
+ return shader;
7308
+ }
7309
+
7310
+ /**
7311
+ * Check Shader status
7312
+ * @param {WebGLRenderingContext} gl The WebGLRenderingContext to use.
7313
+ * @param {WebGLShader} shader The shader
7314
+ * @param {ErrorCallback} [errFn] function to receive error message.
7315
+ * @returns {bool} true if shader is ok.
7316
+ */
7317
+ function checkShaderStatus(gl, shaderType, shader, errFn) {
7318
+ errFn = errFn || error$1;
7285
7319
  // Check the compile status
7286
7320
  const compiled = gl.getShaderParameter(shader, COMPILE_STATUS);
7287
7321
  if (!compiled) {
7288
7322
  // Something went wrong during compilation; get the error
7289
7323
  const lastError = gl.getShaderInfoLog(shader);
7324
+ const shaderType = gl.getShaderParameter(shader, gl.SHADER_TYPE);
7325
+ const {lineOffset, shaderSource} = prepShaderSource(gl.getShaderSource(shader));
7290
7326
  errFn(`${addLineNumbersWithError(shaderSource, lastError, lineOffset)}\nError compiling ${glEnumToString(gl, shaderType)}: ${lastError}`);
7291
- gl.deleteShader(shader);
7292
- return null;
7293
7327
  }
7294
-
7295
- return shader;
7328
+ return compiled;
7296
7329
  }
7297
7330
 
7298
7331
  /**
@@ -7303,6 +7336,7 @@ function loadShader(gl, shaderSource, shaderType, opt_errorCallback) {
7303
7336
  * a BufferInfo will use the attribs names inside. If passed an object of AttribInfos will use the names from that object. Otherwise
7304
7337
  * you can pass an array of names.
7305
7338
  * @property {number} [transformFeedbackMode] the mode to pass `gl.transformFeedbackVaryings`. Defaults to `SEPARATE_ATTRIBS`.
7339
+ * @property {ProgramCallback} [callback] callback for async program compilation.
7306
7340
  * @memberOf module:twgl
7307
7341
  */
7308
7342
 
@@ -7318,6 +7352,7 @@ function loadShader(gl, shaderSource, shaderType, opt_errorCallback) {
7318
7352
  function getProgramOptions(opt_attribs, opt_locations, opt_errorCallback) {
7319
7353
  let transformFeedbackVaryings;
7320
7354
  let transformFeedbackMode;
7355
+ let callback;
7321
7356
  if (typeof opt_locations === 'function') {
7322
7357
  opt_errorCallback = opt_locations;
7323
7358
  opt_locations = undefined;
@@ -7336,12 +7371,14 @@ function getProgramOptions(opt_attribs, opt_locations, opt_errorCallback) {
7336
7371
  opt_attribs = opt.attribLocations;
7337
7372
  transformFeedbackVaryings = opt.transformFeedbackVaryings;
7338
7373
  transformFeedbackMode = opt.transformFeedbackMode;
7374
+ callback = opt.callback;
7339
7375
  }
7340
7376
 
7341
7377
  const options = {
7342
7378
  errorCallback: opt_errorCallback || error$1,
7343
- transformFeedbackVaryings: transformFeedbackVaryings,
7344
- transformFeedbackMode: transformFeedbackMode,
7379
+ transformFeedbackVaryings,
7380
+ transformFeedbackMode,
7381
+ callback,
7345
7382
  };
7346
7383
 
7347
7384
  if (opt_attribs) {
@@ -7379,6 +7416,8 @@ function deleteShaders(gl, shaders) {
7379
7416
  });
7380
7417
  }
7381
7418
 
7419
+ const wait = (ms = 0) => new Promise(resolve => setTimeout(resolve, ms));
7420
+
7382
7421
  /**
7383
7422
  * Creates a program, attaches (and/or compiles) shaders, binds attrib locations, links the
7384
7423
  * program and calls useProgram.
@@ -7401,6 +7440,8 @@ function deleteShaders(gl, shaders) {
7401
7440
  */
7402
7441
  function createProgram(
7403
7442
  gl, shaders, opt_attribs, opt_locations, opt_errorCallback) {
7443
+ // This code is really convoluted, because it may or may not be async
7444
+ // Maybe it would be better to have a separate function
7404
7445
  const progOptions = getProgramOptions(opt_attribs, opt_locations, opt_errorCallback);
7405
7446
  const realShaders = [];
7406
7447
  const newShaders = [];
@@ -7413,7 +7454,11 @@ function createProgram(
7413
7454
  if (elem && elem.type) {
7414
7455
  type = getShaderTypeFromScriptType(gl, elem.type) || type;
7415
7456
  }
7416
- shader = loadShader(gl, src, type, progOptions.errorCallback);
7457
+ shader = loadShader(gl, src, type);
7458
+ if (!progOptions.callback && !checkShaderStatus(gl, shader, opt_errorCallback)) {
7459
+ gl.deleteShader(shader);
7460
+ shader = null;
7461
+ }
7417
7462
  newShaders.push(shader);
7418
7463
  }
7419
7464
  if (isShader(gl, shader)) {
@@ -7446,26 +7491,142 @@ function createProgram(
7446
7491
  }
7447
7492
  gl.transformFeedbackVaryings(program, varyings, progOptions.transformFeedbackMode || SEPARATE_ATTRIBS);
7448
7493
  }
7494
+
7449
7495
  gl.linkProgram(program);
7496
+ if (progOptions.callback) {
7497
+ checkForProgramLinkCompletionAsync(gl, program, progOptions);
7498
+ return null;
7499
+ } else {
7500
+ if (!checkProgramStatus(gl, program, progOptions.errorCallback)) {
7501
+ gl.deleteProgram(program);
7502
+ deleteShaders(gl, newShaders);
7503
+ return null;
7504
+ }
7505
+ return program;
7506
+ }
7507
+ }
7450
7508
 
7509
+ /**
7510
+ * Same as createProgram but returns a promise
7511
+ *
7512
+ * NOTE: There are 4 signatures for this function
7513
+ *
7514
+ * twgl.createProgramAsync(gl, [vs, fs], options);
7515
+ * twgl.createProgramAsync(gl, [vs, fs], opt_errFunc);
7516
+ * twgl.createProgramAsync(gl, [vs, fs], opt_attribs, opt_errFunc);
7517
+ * twgl.createProgramAsync(gl, [vs, fs], opt_attribs, opt_locations, opt_errFunc);
7518
+ *
7519
+ * @param {WebGLRenderingContext} gl The WebGLRenderingContext to use.
7520
+ * @param {WebGLShader[]|string[]} shaders The shaders to attach, or element ids for their source, or strings that contain their source
7521
+ * @param {module:twgl.ProgramOptions|string[]|module:twgl.ErrorCallback} [opt_attribs] Options for the program or an array of attribs names or an error callback. Locations will be assigned by index if not passed in
7522
+ * @param {number[]} [opt_locations|module:twgl.ErrorCallback] The locations for the. A parallel array to opt_attribs letting you assign locations or an error callback.
7523
+ * @param {module:twgl.ErrorCallback} [opt_errorCallback] callback for errors. By default it just prints an error to the console
7524
+ * on error. If you want something else pass an callback. It's passed an error message.
7525
+ * @return {Promise<WebGLProgram>} The created program
7526
+ * @memberOf module:twgl/programs
7527
+ */
7528
+ function createProgramAsync(gl, shaders, ...args) {
7529
+ return new Promise((resolve, reject) => {
7530
+ const programOptions = getProgramOptions(...args);
7531
+ programOptions.callback = (err, program) => {
7532
+ if (err) {
7533
+ reject(err);
7534
+ } else {
7535
+ resolve(program);
7536
+ }
7537
+ };
7538
+ twgl.createProgram(gl, shaders, programOptions);
7539
+ });
7540
+ }
7541
+
7542
+ /**
7543
+ * Same as createProgramInfo but returns a promise
7544
+ * @param {WebGLRenderingContext} gl The WebGLRenderingContext
7545
+ * to use.
7546
+ * @param {string[]} shaderSources Array of sources for the
7547
+ * shaders or ids. The first is assumed to be the vertex shader,
7548
+ * the second the fragment shader.
7549
+ * @param {module:twgl.ProgramOptions|string[]|module:twgl.ErrorCallback} [opt_attribs] Options for the program or an array of attribs names or an error callback. Locations will be assigned by index if not passed in
7550
+ * @param {number[]} [opt_locations|module:twgl.ErrorCallback] The locations for the. A parallel array to opt_attribs letting you assign locations or an error callback.
7551
+ * @param {module:twgl.ErrorCallback} [opt_errorCallback] callback for errors. By default it just prints an error to the console
7552
+ * on error. If you want something else pass an callback. It's passed an error message.
7553
+ * @return {Promise<module:twgl.ProgramInfo>} The created ProgramInfo
7554
+ * @memberOf module:twgl/programs
7555
+ */
7556
+ function createProgramInfoAsync(gl, shaders, ...args) {
7557
+ return new Promise((resolve, reject) => {
7558
+ const programOptions = getProgramOptions(...args);
7559
+ programOptions.callback = (err, programInfo) => {
7560
+ if (err) {
7561
+ reject(err);
7562
+ } else {
7563
+ resolve(programInfo);
7564
+ }
7565
+ };
7566
+ twgl.createProgramInfo(gl, shaders, programOptions);
7567
+ });
7568
+ }
7569
+
7570
+
7571
+ /**
7572
+ * Asynchronously wait for program to link.
7573
+ * Note: if 'KHR_parallel_shader_compile' extension does not
7574
+ * exist then compilation will not be truly async.
7575
+ * @param {WebGLRenderingContext} gl The context
7576
+ * @param {WebGLProgram} program The program
7577
+ * @param {module:twgl.ProgramOptions} progOptions Options for the program or an array of attribs names or an error callback. Locations will be assigned by index if not passed in
7578
+ */
7579
+ async function checkForProgramLinkCompletionAsync(gl, program, progOptions) {
7580
+ const ext = gl.getExtension('KHR_parallel_shader_compile');
7581
+ const checkFn = ext
7582
+ ? (gl, program) => gl.getProgramParameter(program, ext.COMPLETION_STATUS_KHR)
7583
+ : () => true;
7584
+
7585
+ let waitTime = 0;
7586
+ do {
7587
+ await wait(waitTime); // must wait at least once
7588
+ waitTime = 1000 / 60;
7589
+ } while (!checkFn(gl, program));
7590
+
7591
+ const errMsgs = [];
7592
+ const success = checkProgramStatus(gl, program, (msg) => errMsgs.push(msg));
7593
+ const err = success ? undefined : errMsgs.join('\n');
7594
+ if (!success) {
7595
+ const errFn = progOptions.errorCallback || error$1;
7596
+ errFn(err);
7597
+ gl.deleteProgram(program);
7598
+ // TODO: delete shaders, but only shaders that were created newly for this
7599
+ // program
7600
+ program = null;
7601
+ }
7602
+ progOptions.callback(err, program);
7603
+ }
7604
+
7605
+ /**
7606
+ * Check a program's link status
7607
+ * @param {WebGLRenderingContext} gl The WebGLRenderingContext to use.
7608
+ * @param {WebGLProgram} program Program to check
7609
+ * @param {ErrorCallback} [errFn] func for errors
7610
+ * @return {bool} true if program is ok
7611
+ */
7612
+ function checkProgramStatus(gl, program, errFn) {
7613
+ errFn = errFn || error$1;
7451
7614
  // Check the link status
7452
7615
  const linked = gl.getProgramParameter(program, LINK_STATUS);
7453
7616
  if (!linked) {
7454
7617
  // something went wrong with the link
7455
7618
  const lastError = gl.getProgramInfoLog(program);
7456
- progOptions.errorCallback(`${
7457
- realShaders.map(shader => {
7458
- const src = addLineNumbersWithError(gl.getShaderSource(shader), '', 0);
7619
+ errFn(`${
7620
+ gl.getAttachedShaders(program).map(shader => {
7621
+ const {lineOffset, shaderSource} = prepShaderSource(gl.getShaderSource(shader));
7622
+ const shaderError = gl.getShaderInfoLog(shader);
7623
+ const src = addLineNumbersWithError(shaderSource, shaderError, lineOffset);
7459
7624
  const type = gl.getShaderParameter(shader, gl.SHADER_TYPE);
7460
7625
  return `${glEnumToString(gl, type)}\n${src}}`;
7461
7626
  }).join('\n')
7462
7627
  }\nError in program linking: ${lastError}`);
7463
-
7464
- gl.deleteProgram(program);
7465
- deleteShaders(gl, newShaders);
7466
- return null;
7467
7628
  }
7468
- return program;
7629
+ return linked;
7469
7630
  }
7470
7631
 
7471
7632
  /**
@@ -7492,7 +7653,7 @@ function createShaderFromScript(
7492
7653
  throw new Error('unknown shader type');
7493
7654
  }
7494
7655
 
7495
- return loadShader(gl, shaderSource, shaderType, opt_errorCallback);
7656
+ return loadShader(gl, shaderSource, shaderType);
7496
7657
  }
7497
7658
 
7498
7659
  /**
@@ -8574,6 +8735,8 @@ function createProgramInfoFromProgram(gl, program) {
8574
8735
  return programInfo;
8575
8736
  }
8576
8737
 
8738
+ const notIdRE = /\s|{|}|;/;
8739
+
8577
8740
  /**
8578
8741
  * Creates a ProgramInfo from 2 sources.
8579
8742
  *
@@ -8607,25 +8770,40 @@ function createProgramInfoFromProgram(gl, program) {
8607
8770
  function createProgramInfo(
8608
8771
  gl, shaderSources, opt_attribs, opt_locations, opt_errorCallback) {
8609
8772
  const progOptions = getProgramOptions(opt_attribs, opt_locations, opt_errorCallback);
8610
- let good = true;
8773
+ const errors = [];
8611
8774
  shaderSources = shaderSources.map(function(source) {
8612
8775
  // Lets assume if there is no \n it's an id
8613
- if (source.indexOf("\n") < 0) {
8776
+ if (!notIdRE.test(source)) {
8614
8777
  const script = getElementById(source);
8615
8778
  if (!script) {
8616
- progOptions.errorCallback("no element with id: " + source);
8617
- good = false;
8779
+ const err = `no element with id: ${source}`;
8780
+ progOptions.errorCallback(err);
8781
+ errors.push(err);
8618
8782
  } else {
8619
8783
  source = script.text;
8620
8784
  }
8621
8785
  }
8622
8786
  return source;
8623
8787
  });
8624
- if (!good) {
8788
+ if (errors.length) {
8789
+ if (progOptions.callback) {
8790
+ progOptions.callback(errors.join('\n'));
8791
+ }
8625
8792
  return null;
8626
8793
  }
8794
+ const origCallback = progOptions.callback;
8795
+ if (origCallback) {
8796
+ progOptions.callback = (err, program) => {
8797
+ let programInfo;
8798
+ if (!err) {
8799
+ programInfo = createProgramInfoFromProgram(gl, program);
8800
+ }
8801
+ origCallback(err, programInfo);
8802
+ };
8803
+ }
8627
8804
  const program = createProgramFromSources(gl, shaderSources, progOptions);
8628
8805
  if (!program) {
8806
+ // we should never get if if we have a callback
8629
8807
  return null;
8630
8808
  }
8631
8809
  return createProgramInfoFromProgram(gl, program);
@@ -8635,9 +8813,11 @@ var programs = /*#__PURE__*/Object.freeze({
8635
8813
  __proto__: null,
8636
8814
  createAttributeSetters: createAttributeSetters,
8637
8815
  createProgram: createProgram,
8816
+ createProgramAsync: createProgramAsync,
8638
8817
  createProgramFromScripts: createProgramFromScripts,
8639
8818
  createProgramFromSources: createProgramFromSources,
8640
8819
  createProgramInfo: createProgramInfo,
8820
+ createProgramInfoAsync: createProgramInfoAsync,
8641
8821
  createProgramInfoFromProgram: createProgramInfoFromProgram,
8642
8822
  createUniformSetters: createUniformSetters,
8643
8823
  createUniformBlockSpecFromProgram: createUniformBlockSpecFromProgram,
@@ -9662,4 +9842,4 @@ function resizeCanvasToDisplaySize(canvas, multiplier) {
9662
9842
  return false;
9663
9843
  }
9664
9844
 
9665
- export { addExtensionsToContext, attributes, bindFramebufferInfo, bindTransformFeedbackInfo, bindUniformBlock, canFilter, canGenerateMipmap, createAttribsFromArrays, createAttributeSetters, createBufferFromArray, createBufferFromTypedArray, createBufferInfoFromArrays, createBuffersFromArrays, createFramebufferInfo, createProgram, createProgramFromScripts, createProgramFromSources, createProgramInfo, createProgramInfoFromProgram, createSampler, createSamplers, createTexture, createTextures, createTransformFeedback, createTransformFeedbackInfo, createUniformBlockInfo, createUniformBlockInfoFromProgram, createUniformBlockSpecFromProgram, createUniformSetters, createVAOAndSetAttributes, createVAOFromBufferInfo, createVertexArrayInfo, draw, drawBufferInfo, drawObjectList, framebuffers, getArray as getArray_, getBytesPerElementForInternalFormat, getContext, getFormatAndTypeForInternalFormat, getGLTypeForTypedArray, getGLTypeForTypedArrayType, getNumComponentsForFormat, getNumComponents as getNumComponents_, getTypedArrayTypeForGLType, getWebGLContext, glEnumToString, isArrayBuffer, isWebGL1, isWebGL2, loadTextureFromUrl, m4, primitives, programs, resizeCanvasToDisplaySize, resizeFramebufferInfo, resizeTexture, setAttribInfoBufferFromArray, setDefaults as setAttributeDefaults_, setAttributePrefix, setAttributes, setBlockUniforms, setBuffersAndAttributes, setDefaultTextureColor, setDefaults$2 as setDefaults, setEmptyTexture, setSamplerParameters, setDefaults$1 as setTextureDefaults_, setTextureFilteringForSize, setTextureFromArray, setTextureFromElement, setTextureParameters, setUniformBlock, setUniforms, setUniformsAndBindTextures, textures, typedarrays, utils, v3, vertexArrays };
9845
+ export { addExtensionsToContext, attributes, bindFramebufferInfo, bindTransformFeedbackInfo, bindUniformBlock, canFilter, canGenerateMipmap, createAttribsFromArrays, createAttributeSetters, createBufferFromArray, createBufferFromTypedArray, createBufferInfoFromArrays, createBuffersFromArrays, createFramebufferInfo, createProgram, createProgramAsync, createProgramFromScripts, createProgramFromSources, createProgramInfo, createProgramInfoAsync, createProgramInfoFromProgram, createSampler, createSamplers, createTexture, createTextures, createTransformFeedback, createTransformFeedbackInfo, createUniformBlockInfo, createUniformBlockInfoFromProgram, createUniformBlockSpecFromProgram, createUniformSetters, createVAOAndSetAttributes, createVAOFromBufferInfo, createVertexArrayInfo, draw, drawBufferInfo, drawObjectList, framebuffers, getArray as getArray_, getBytesPerElementForInternalFormat, getContext, getFormatAndTypeForInternalFormat, getGLTypeForTypedArray, getGLTypeForTypedArrayType, getNumComponentsForFormat, getNumComponents as getNumComponents_, getTypedArrayTypeForGLType, getWebGLContext, glEnumToString, isArrayBuffer, isWebGL1, isWebGL2, loadTextureFromUrl, m4, primitives, programs, resizeCanvasToDisplaySize, resizeFramebufferInfo, resizeTexture, setAttribInfoBufferFromArray, setDefaults as setAttributeDefaults_, setAttributePrefix, setAttributes, setBlockUniforms, setBuffersAndAttributes, setDefaultTextureColor, setDefaults$2 as setDefaults, setEmptyTexture, setSamplerParameters, setDefaults$1 as setTextureDefaults_, setTextureFilteringForSize, setTextureFromArray, setTextureFromElement, setTextureParameters, setUniformBlock, setUniforms, setUniformsAndBindTextures, textures, typedarrays, utils, v3, vertexArrays };
@@ -89,6 +89,7 @@ export type ProgramOptions = {
89
89
  [key: string]: AttribInfo;
90
90
  } | string[];
91
91
  transformFeedbackMode?: number;
92
+ callback?: ProgramCallback;
92
93
  };
93
94
  export type TransformFeedbackInfo = {
94
95
  index: number;
@@ -256,7 +257,14 @@ export function bindFramebufferInfo(gl: WebGLRenderingContext, framebufferInfo?:
256
257
 
257
258
 
258
259
  export function getBindPointForSamplerType(): void;
260
+ export type ProgramCallback = (err?: string, result?: WebGLProgram | ProgramInfo) => void;
261
+ export function prepShaderSource(shaderSource: string): any;
262
+ export function checkShaderStatus(gl: WebGLRenderingContext, shader: WebGLShader, errFn?: ErrorCallback): boolean;
259
263
  export function createProgram(gl: WebGLRenderingContext, shaders: WebGLShader[] | string[], opt_attribs?: ProgramOptions | string[] | ErrorCallback, opt_errorCallback?: ErrorCallback): WebGLProgram;
264
+ export function createProgramAsync(gl: WebGLRenderingContext, shaders: WebGLShader[] | string[], opt_attribs?: ProgramOptions | string[] | ErrorCallback, opt_errorCallback?: ErrorCallback): Promise<WebGLProgram>;
265
+ export function createProgramInfoAsync(gl: WebGLRenderingContext, shaderSources: string[], opt_attribs?: ProgramOptions | string[] | ErrorCallback, opt_errorCallback?: ErrorCallback): Promise<ProgramInfo>;
266
+ export function checkForProgramLinkCompletionAsync(gl: WebGLRenderingContext, program: WebGLProgram, progOptions: ProgramOptions): void;
267
+ export function checkProgramStatus(gl: WebGLRenderingContext, program: WebGLProgram, errFn?: ErrorCallback): boolean;
260
268
  export function createProgramFromScripts(gl: WebGLRenderingContext, shaderScriptIds: string[], opt_attribs?: ProgramOptions | string[] | ErrorCallback, opt_errorCallback?: ErrorCallback): WebGLProgram;
261
269
  export function createProgramFromSources(gl: WebGLRenderingContext, shaderSources: string[], opt_attribs?: ProgramOptions | string[] | ErrorCallback, opt_errorCallback?: ErrorCallback): WebGLProgram;
262
270
  export function createUniformSetters(gl: WebGLRenderingContext, program: WebGLProgram): {