@@ -591,6 +591,7 @@ export type UniformBlockSpec = {
591
591
* @property {ArrayBuffer } array The array buffer that contains the uniform values
592
592
* @property {Float32Array } asFloat A float view on the array buffer. This is useful
593
593
* inspecting the contents of the buffer in the debugger.
594
+ * @property {Uint8Array } asUint8t A uint8 view on the array buffer.
594
595
* @property {WebGLBuffer } buffer A WebGL buffer that will hold a copy of the uniform values for rendering.
595
596
* @property {number } [offset] offset into buffer
596
597
* @property {Object<string, ArrayBufferView> } uniforms A uniform name to ArrayBufferView map.
@@ -612,6 +613,7 @@ export type UniformBlockInfo = {
612
613
name : string ;
613
614
array : ArrayBuffer ;
614
615
asFloat : Float32Array ;
616
+ asUint8t : Uint8Array ;
615
617
buffer : WebGLBuffer ;
616
618
offset ?: number ;
617
619
uniforms : {
@@ -624,6 +626,8 @@ export type UniformBlockInfo = {
624
626
/**
625
627
* @typedef {Object } ProgramInfo
626
628
* @property {WebGLProgram } program A shader program
629
+ * @property {Object<string, WebGLUniformLocation> } uniformLocations The uniform locations of each uniform
630
+ * @property {Object<string, number> } attribLocations The locations of each attribute
627
631
* @property {Object<string, function> } uniformSetters object of setters as returned from createUniformSetters,
628
632
* @property {Object<string, function> } attribSetters object of setters as returned from createAttribSetters,
629
633
* @property {UniformBlockSpec } [uniformBlockSpec] a uniform block spec for making UniformBlockInfos with createUniformBlockInfo etc..
@@ -632,6 +636,12 @@ export type UniformBlockInfo = {
632
636
*/
633
637
export type ProgramInfo = {
634
638
program : WebGLProgram ;
639
+ uniformLocations : {
640
+ [ key : string ] : WebGLUniformLocation ;
641
+ } ;
642
+ attribLocations : {
643
+ [ key : string ] : number ;
644
+ } ;
635
645
uniformSetters : {
636
646
[ key : string ] : ( ...params : any [ ] ) => any ;
637
647
} ;
@@ -1211,10 +1221,11 @@ export function createProgramInfo(gl: WebGLRenderingContext, shaderSources: stri
1211
1221
* @param {ProgramInfo } programInfo a `ProgramInfo`
1212
1222
* as returned from {@link createProgramInfo}
1213
1223
* @param {string } blockName The name of the block.
1224
+ * @param {UniformBlockInfoOptions } [options] Optional options for using existing an existing buffer and arrayBuffer
1214
1225
* @return {UniformBlockInfo } The created UniformBlockInfo
1215
1226
* @memberOf module:twgl/programs
1216
1227
*/
1217
- export function createUniformBlockInfo ( gl : WebGL2RenderingContext , programInfo : ProgramInfo , blockName : string ) : UniformBlockInfo ;
1228
+ export function createUniformBlockInfo ( gl : WebGL2RenderingContext , programInfo : ProgramInfo , blockName : string , options ?: UniformBlockInfoOptions ) : UniformBlockInfo ;
1218
1229
/**
1219
1230
* Binds a uniform block to the matching uniform block point.
1220
1231
* Matches by blocks by name so blocks must have the same name not just the same
@@ -2222,6 +2233,20 @@ export function createUniformSetters(gl: WebGLRenderingContext, program: WebGLPr
2222
2233
* @memberOf module:twgl/programs
2223
2234
*/
2224
2235
export function createUniformBlockSpecFromProgram ( gl : WebGL2RenderingContext , program : WebGLProgram ) : UniformBlockSpec ;
2236
+ /**
2237
+ * Options to allow createUniformBlockInfo to use an existing buffer and arrayBuffer at an offset
2238
+ * @typedef {Object } UniformBlockInfoOptions
2239
+ * @property {ArrayBuffer } [array] an existing array buffer to use for values
2240
+ * @property {number } [offset] the offset in bytes to use in the array buffer (default = 0)
2241
+ * @property {WebGLBuffer } [buffer] the buffer to use for this uniform block info
2242
+ * @property {number } [bufferOffset] the offset in bytes in the buffer to use (default = use offset above)
2243
+ */
2244
+ export type UniformBlockInfoOptions = {
2245
+ array ?: ArrayBuffer ;
2246
+ offset ?: number ;
2247
+ buffer ?: WebGLBuffer ;
2248
+ bufferOffset ?: number ;
2249
+ } ;
2225
2250
/**
2226
2251
* Creates a `UniformBlockInfo` for the specified block
2227
2252
*
@@ -2236,10 +2261,11 @@ export function createUniformBlockSpecFromProgram(gl: WebGL2RenderingContext, pr
2236
2261
* @param {UniformBlockSpec } uniformBlockSpec. A UniformBlockSpec as returned
2237
2262
* from {@link createUniformBlockSpecFromProgram}.
2238
2263
* @param {string } blockName The name of the block.
2264
+ * @param {UniformBlockInfoOptions } [options] Optional options for using existing an existing buffer and arrayBuffer
2239
2265
* @return {UniformBlockInfo } The created UniformBlockInfo
2240
2266
* @memberOf module:twgl/programs
2241
2267
*/
2242
- export function createUniformBlockInfoFromProgram ( gl : WebGL2RenderingContext , program : WebGLProgram , blockName : string ) : UniformBlockInfo ;
2268
+ export function createUniformBlockInfoFromProgram ( gl : WebGL2RenderingContext , program : WebGLProgram , blockName : string , options ?: UniformBlockInfoOptions ) : UniformBlockInfo ;
2243
2269
/**
2244
2270
* Creates a `UniformBlockInfo` for the specified block
2245
2271
*
@@ -2253,10 +2279,11 @@ export function createUniformBlockInfoFromProgram(gl: WebGL2RenderingContext, pr
2253
2279
* @param {ProgramInfo } programInfo a `ProgramInfo`
2254
2280
* as returned from {@link createProgramInfo}
2255
2281
* @param {string } blockName The name of the block.
2282
+ * @param {UniformBlockInfoOptions } [options] Optional options for using existing an existing buffer and arrayBuffer
2256
2283
* @return {UniformBlockInfo } The created UniformBlockInfo
2257
2284
* @memberOf module:twgl/programs
2258
2285
*/
2259
- export function createUniformBlockInfo ( gl : WebGL2RenderingContext , programInfo : ProgramInfo , blockName : string ) : UniformBlockInfo ;
2286
+ export function createUniformBlockInfo ( gl : WebGL2RenderingContext , programInfo : ProgramInfo , blockName : string , options ?: UniformBlockInfoOptions ) : UniformBlockInfo ;
2260
2287
/**
2261
2288
* Binds a uniform block to the matching uniform block point.
2262
2289
* Matches by blocks by name so blocks must have the same name not just the same
0 commit comments