@@ -101,15 +101,15 @@ export default async function demo({
101
101
} ;
102
102
103
103
const uni = {
104
- sheetBounds : mustGetUniform ( 'sheetBounds' ) , // mediump vec2
104
+ sheetBounds : mustGetUniform ( 'sheetBounds' ) , // uvec2
105
105
sheet : mustGetUniform ( 'sheet' ) , // sampler2D
106
106
perspective : mustGetUniform ( 'perspective' ) , // mediump mat4
107
107
} ;
108
108
109
109
const attr = {
110
- tileID : mustGetAttr ( 'tileID' ) , // float
111
110
loc : mustGetAttr ( 'loc' ) , // vec2
112
111
size : mustGetAttr ( 'size' ) , // float
112
+ tileID : mustGetAttr ( 'tileID' ) , // uvec2
113
113
} ;
114
114
115
115
/// notes from https://webglfundamentals.org/webgl/lessons/webgl-and-alpha.html
@@ -156,7 +156,6 @@ export default async function demo({
156
156
157
157
let tileSize = 0 ;
158
158
let maxTileID = 0 ;
159
- let sheetBounds = { x : 0 , y : 0 } ;
160
159
161
160
const perspective = mat4 . identity ( new Float32Array ( 16 ) ) ;
162
161
@@ -267,7 +266,7 @@ export default async function demo({
267
266
gl . vertexAttribPointer ( attr . loc , 2 , gl . FLOAT , false , 0 , 0 ) ;
268
267
269
268
gl . bindBuffer ( gl . ARRAY_BUFFER , tileBuffer )
270
- gl . vertexAttribPointer ( attr . tileID , 1 , gl . UNSIGNED_SHORT , false , 0 , 0 ) ;
269
+ gl . vertexAttribIPointer ( attr . tileID , 1 , gl . UNSIGNED_SHORT , 0 , 0 ) ;
271
270
272
271
/// per frame drawing pass
273
272
gl . clear ( gl . COLOR_BUFFER_BIT ) ;
@@ -277,10 +276,16 @@ export default async function demo({
277
276
278
277
}
279
278
279
+ // [.WebGL-0x104015f3800] GL_INVALID_OPERATION: Uniform size does not match uniform method.
280
+ // gldemo.html:1 [.WebGL-0x104015f3800] GL_INVALID_OPERATION: Uniform size does not match uniform method.
281
+ // 253[.WebGL-0x104015f3800] GL_INVALID_OPERATION: Vertex shader input type does not match the type of the bound vertex attribute.
282
+ // gldemo.html:1 [.WebGL-0x104015f3800] GL_INVALID_OPERATION: Uniform size does not match uniform method.
283
+ // gldemo.html:1 WebGL: too many errors, no more errors will be reported to the console for this context.
284
+
280
285
function updateSheetTex ( ) {
281
- sheetBounds . x = Math . floor ( $sheet . width / tileSize ) ;
282
- sheetBounds . y = Math . floor ( $sheet . height / tileSize ) ;
283
- gl . uniform2f ( uni . sheetBounds , sheetBounds . x , sheetBounds . y ) ;
286
+ gl . uniform2ui ( uni . sheetBounds ,
287
+ Math . floor ( $sheet . width / tileSize ) ,
288
+ Math . floor ( $sheet . height / tileSize ) ) ;
284
289
285
290
gl . activeTexture ( sheetTexUnit ) ;
286
291
gl . bindTexture ( sheetTexTarget , sheetTex ) ;
0 commit comments