@@ -133,17 +133,18 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
133
133
this . context . bindRenderbuffer ( target , value ) ;
134
134
}
135
135
136
- _lastTexture : {
137
- target : number ,
138
- texture : number
139
- } = { target : 0 , texture : 0 }
136
+ _lastTexture : {
137
+ target : number ;
138
+ texture : number ;
139
+ } = { target : 0 , texture : 0 } ;
140
140
bindTexture ( target : number , texture : WebGLTexture ) : void {
141
141
this . _glCheckError ( 'bindTexture' ) ;
142
142
this . _checkArgs ( 'bindTexture' , arguments ) ;
143
143
const value = texture ? texture . native : 0 ;
144
- if ( value > 0 ) {
144
+ if ( value > 0 ) {
145
145
this . _lastTexture = {
146
- target, texture : value
146
+ target,
147
+ texture : value ,
147
148
} ;
148
149
}
149
150
@@ -695,19 +696,19 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
695
696
return new Float32Array ( this . getJSArray ( value ) ) ;
696
697
case this . ARRAY_BUFFER_BINDING :
697
698
case this . ELEMENT_ARRAY_BUFFER_BINDING :
698
- if ( value ) {
699
+ if ( value ) {
699
700
new WebGLBuffer ( WebGLRenderingContext . toPrimitive ( value ) ) ;
700
701
}
701
702
return null ;
702
703
case this . CURRENT_PROGRAM :
703
- if ( value ) {
704
+ if ( value ) {
704
705
return new WebGLProgram ( WebGLRenderingContext . toPrimitive ( value ) ) ;
705
706
}
706
707
return null ;
707
708
case this . COMPRESSED_TEXTURE_FORMATS :
708
709
return new Uint32Array ( this . getJSArray ( value ) ) ;
709
710
case this . RENDERBUFFER_BINDING :
710
- if ( value ) {
711
+ if ( value ) {
711
712
return new WebGLRenderbuffer ( WebGLRenderingContext . toPrimitive ( value ) ) ;
712
713
}
713
714
return null ;
@@ -1039,7 +1040,13 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
1039
1040
this . context . texImage2D ( target , level , internalformat , width , height , border , format , type , this . toNativeArray ( pixels as any , 'float' ) ) ;
1040
1041
}
1041
1042
} else if ( pixels instanceof ArrayBuffer ) {
1042
- this . context . texImage2D ( target , level , internalformat , width , height , border , format , type , this . toNativeArray ( new Uint8Array ( pixels as any ) as any , 'byte' ) ) ;
1043
+ // @ts -ignore // ArrayBuffer backed by nio buffer
1044
+ if ( pixels . nativeObject ) {
1045
+ // @ts -ignore
1046
+ this . context . texImage2D ( target , level , internalformat , width , height , border , format , type , pixels . nativeObject ) ;
1047
+ } else {
1048
+ this . context . texImage2D ( target , level , internalformat , width , height , border , format , type , this . toNativeArray ( new Uint8Array ( pixels as any ) as any , 'byte' ) ) ;
1049
+ }
1043
1050
} else {
1044
1051
this . context . texImage2D ( target , level , internalformat , width , height , border , format , type , pixels as any ) ;
1045
1052
}
@@ -1147,7 +1154,7 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
1147
1154
uniform1fv ( location : WebGLUniformLocation , value : number [ ] ) : void {
1148
1155
this . _glCheckError ( 'uniform1fv' ) ;
1149
1156
this . _checkArgs ( 'uniform1fv' , arguments ) ;
1150
- value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1157
+ value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1151
1158
const loc = location ? location . native : 0 ;
1152
1159
this . context . uniform1fv ( loc , value ) ;
1153
1160
}
@@ -1169,15 +1176,15 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
1169
1176
uniform2iv ( location : WebGLUniformLocation , value : number [ ] ) : void {
1170
1177
this . _glCheckError ( 'uniform2iv' ) ;
1171
1178
this . _checkArgs ( 'uniform2iv' , arguments ) ;
1172
- value = Array . from ( value ) ; //this.toNativeArray(value, 'int');
1179
+ value = Array . from ( value ) ; //this.toNativeArray(value, 'int');
1173
1180
const loc = location ? location . native : 0 ;
1174
1181
this . context . uniform2iv ( loc , value ) ;
1175
1182
}
1176
1183
1177
1184
uniform2fv ( location : WebGLUniformLocation , value : number [ ] ) : void {
1178
1185
this . _glCheckError ( 'uniform2fv' ) ;
1179
1186
this . _checkArgs ( 'uniform2fv' , arguments ) ;
1180
- value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1187
+ value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1181
1188
const loc = location ? location . native : 0 ;
1182
1189
this . context . uniform2fv ( loc , value ) ;
1183
1190
}
@@ -1199,15 +1206,15 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
1199
1206
uniform3iv ( location : WebGLUniformLocation , value : number [ ] ) : void {
1200
1207
this . _glCheckError ( 'uniform3iv' ) ;
1201
1208
this . _checkArgs ( 'uniform3iv' , arguments ) ;
1202
- value = Array . from ( value ) ; //this.toNativeArray(value, 'int');
1209
+ value = Array . from ( value ) ; //this.toNativeArray(value, 'int');
1203
1210
const loc = location ? location . native : 0 ;
1204
1211
this . context . uniform3iv ( loc , value ) ;
1205
1212
}
1206
1213
1207
1214
uniform3fv ( location : WebGLUniformLocation , value : number [ ] ) : void {
1208
1215
this . _glCheckError ( 'uniform3fv' ) ;
1209
1216
this . _checkArgs ( 'uniform3fv' , arguments ) ;
1210
- value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1217
+ value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1211
1218
const loc = location ? location . native : 0 ;
1212
1219
this . context . uniform3fv ( loc , value ) ;
1213
1220
}
@@ -1229,15 +1236,15 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
1229
1236
uniform4iv ( location : WebGLUniformLocation , value : number [ ] ) : void {
1230
1237
this . _glCheckError ( 'uniform4iv' ) ;
1231
1238
this . _checkArgs ( 'uniform4iv' , arguments ) ;
1232
- value = Array . from ( value ) ; //this.toNativeArray(value, 'int');
1239
+ value = Array . from ( value ) ; //this.toNativeArray(value, 'int');
1233
1240
const loc = location ? location . native : 0 ;
1234
1241
this . context . uniform4iv ( loc , value ) ;
1235
1242
}
1236
1243
1237
1244
uniform4fv ( location : WebGLUniformLocation , value : number [ ] ) : void {
1238
1245
this . _glCheckError ( 'uniform4fv' ) ;
1239
1246
this . _checkArgs ( 'uniform4fv' , arguments ) ;
1240
- value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1247
+ value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1241
1248
const loc = location ? location . native : 0 ;
1242
1249
this . context . uniform4fv ( loc , value ) ;
1243
1250
}
@@ -1252,23 +1259,23 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
1252
1259
uniformMatrix2fv ( location : WebGLUniformLocation , transpose : boolean , value : number [ ] ) : void {
1253
1260
this . _glCheckError ( 'uniformMatrix2fv' ) ;
1254
1261
this . _checkArgs ( 'uniformMatrix2fv' , arguments ) ;
1255
- value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1262
+ value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1256
1263
const loc = location ? location . native : 0 ;
1257
1264
this . context . uniformMatrix2fv ( loc , transpose , value ) ;
1258
1265
}
1259
1266
1260
1267
uniformMatrix3fv ( location : WebGLUniformLocation , transpose : boolean , value : number [ ] ) : void {
1261
1268
this . _glCheckError ( 'uniformMatrix3fv' ) ;
1262
1269
this . _checkArgs ( 'uniformMatrix3fv' , arguments ) ;
1263
- value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1270
+ value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1264
1271
const loc = location ? location . native : 0 ;
1265
1272
this . context . uniformMatrix3fv ( loc , transpose , value ) ;
1266
1273
}
1267
1274
1268
1275
uniformMatrix4fv ( location : WebGLUniformLocation , transpose : boolean , value : number [ ] ) : void {
1269
1276
this . _glCheckError ( 'uniformMatrix4fv' ) ;
1270
1277
this . _checkArgs ( 'uniformMatrix4fv' , arguments ) ;
1271
- value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1278
+ value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1272
1279
const loc = location ? location . native : 0 ;
1273
1280
this . context . uniformMatrix4fv ( loc , transpose , value ) ;
1274
1281
}
@@ -1296,7 +1303,7 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
1296
1303
vertexAttrib1fv ( index : number , value : number [ ] ) : void {
1297
1304
this . _glCheckError ( 'vertexAttrib1fv' ) ;
1298
1305
this . _checkArgs ( 'vertexAttrib1fv' , arguments ) ;
1299
- value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1306
+ value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1300
1307
this . context . vertexAttrib1fv ( index , value ) ;
1301
1308
}
1302
1309
@@ -1309,7 +1316,7 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
1309
1316
vertexAttrib2fv ( index : number , value : number [ ] ) : void {
1310
1317
this . _glCheckError ( 'vertexAttrib2fv' ) ;
1311
1318
this . _checkArgs ( 'vertexAttrib2fv' , arguments ) ;
1312
- value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1319
+ value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1313
1320
this . context . vertexAttrib2fv ( index , value ) ;
1314
1321
}
1315
1322
@@ -1322,7 +1329,7 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
1322
1329
vertexAttrib3fv ( index : number , value : number [ ] ) : void {
1323
1330
this . _glCheckError ( 'vertexAttrib3fv' ) ;
1324
1331
this . _checkArgs ( 'vertexAttrib3fv' , arguments ) ;
1325
- value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1332
+ value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1326
1333
this . context . vertexAttrib3fv ( index , value ) ;
1327
1334
}
1328
1335
@@ -1335,7 +1342,7 @@ export class WebGLRenderingContext extends WebGLRenderingContextBase {
1335
1342
vertexAttrib4fv ( index : number , value : number [ ] ) : void {
1336
1343
this . _glCheckError ( 'vertexAttrib4fv' ) ;
1337
1344
this . _checkArgs ( 'vertexAttrib4fv' , arguments ) ;
1338
- value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1345
+ value = Array . from ( value ) ; //this.toNativeArray(value, 'float');
1339
1346
this . context . vertexAttrib4fv ( index , value ) ;
1340
1347
}
1341
1348
0 commit comments