forked from stackgl/headless-gl
-
Notifications
You must be signed in to change notification settings - Fork 4
/
webgl.js
1095 lines (957 loc) · 49.3 KB
/
webgl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"use strict";
var GL = module.exports = require('./build/Release/webgl.node');
var WebGLRenderingContext = GL.WebGLRenderingContext;
var gl = WebGLRenderingContext.prototype;
gl.WebGLProgram=function (_) { this._ = _; }
gl.WebGLShader=function (_) { this._ = _; }
gl.WebGLBuffer=function (_) { this._ = _; }
gl.WebGLFramebuffer=function (_) { this._ = _; }
gl.WebGLRenderbuffer=function (_) { this._ = _; }
gl.WebGLTexture=function (_) { this._ = _; }
gl.WebGLActiveInfo=function (_) { this._=_; this.size=_.size; this.type=_.type; this.name=_.name; }
gl.WebGLUniformLocation=function (_) { this._ = _; }
////////////////////////////////////////////////////////////////////////////////
var _getSupportedExtensions = gl.getSupportedExtensions;
gl.getSupportedExtensions = function getSupportedExtensions() {
return _getSupportedExtensions.call(this).split(" ");
}
var _activeTexture = gl.activeTexture;
gl.activeTexture = function activeTexture(texture) {
if (!(arguments.length === 1 && typeof texture === "number")) {
throw new TypeError('Expected activeTexture(number texture)');
}
return _activeTexture.call(this, texture);
}
var _attachShader = gl.attachShader;
gl.attachShader = function attachShader(program, shader) {
if (!(arguments.length === 2 && (program === null || program instanceof gl.WebGLProgram) && (shader === null || shader instanceof gl.WebGLShader))) {
throw new TypeError('Expected attachShader(WebGLProgram program, WebGLShader shader)');
}
return _attachShader.call(this, program ? program._ : 0, shader ? shader._ : 0);
}
var _bindAttribLocation = gl.bindAttribLocation;
gl.bindAttribLocation = function bindAttribLocation(program, index, name) {
if (!(arguments.length === 3 && (program === null || program instanceof gl.WebGLProgram) && typeof index === "number" && typeof name === "string")) {
throw new TypeError('Expected bindAttribLocation(WebGLProgram program, number index, string name)');
}
return _bindAttribLocation.call(this, program ? program._ : 0, index, name);
}
var _bindBuffer = gl.bindBuffer;
gl.bindBuffer = function bindBuffer(target, buffer) {
if (!(arguments.length === 2 && typeof target === "number" && (buffer === null || buffer instanceof gl.WebGLBuffer))) {
throw new TypeError('Expected bindBuffer(number target, WebGLBuffer buffer)');
}
return _bindBuffer.call(this, target, buffer ? buffer._ : 0);
}
var _bindFramebuffer = gl.bindFramebuffer;
gl.bindFramebuffer = function bindFramebuffer(target, framebuffer) {
if (!(arguments.length === 2 && typeof target === "number" && (framebuffer === null || framebuffer instanceof gl.WebGLFramebuffer))) {
throw new TypeError('Expected bindFramebuffer(number target, WebGLFramebuffer framebuffer)');
}
return _bindFramebuffer.call(this, target, framebuffer ? framebuffer._ : 0);
}
var _bindRenderbuffer = gl.bindRenderbuffer;
gl.bindRenderbuffer = function bindRenderbuffer(target, renderbuffer) {
if (!(arguments.length === 2 && typeof target === "number" && (renderbuffer === null || renderbuffer instanceof gl.WebGLRenderbuffer))) {
throw new TypeError('Expected bindRenderbuffer(number target, WebGLRenderbuffer renderbuffer)');
}
return _bindRenderbuffer.call(this, target, renderbuffer ? renderbuffer._ : 0);
}
var _bindTexture = gl.bindTexture;
gl.bindTexture = function bindTexture(target, texture) {
if (!(arguments.length === 2 && typeof target === "number" && (texture === null || texture instanceof gl.WebGLTexture))) {
throw new TypeError('Expected bindTexture(number target, WebGLTexture texture)');
}
return _bindTexture.call(this, target, texture ? texture._ : 0);
}
var _blendColor = gl.blendColor;
gl.blendColor = function blendColor(red, green, blue, alpha) {
if (!(arguments.length === 4 && typeof red === "number" && typeof green === "number" && typeof blue === "number" && typeof alpha === "number")) {
throw new TypeError('Expected blendColor(number red, number green, number blue, number alpha)');
}
return _blendColor.call(this, red, green, blue, alpha);
}
var _blendEquation = gl.blendEquation;
gl.blendEquation = function blendEquation(mode) {
if (!(arguments.length === 1 && typeof mode === "number")) {
throw new TypeError('Expected blendEquation(number mode)');
}
return _blendEquation.call(this, mode);
}
var _blendEquationSeparate = gl.blendEquationSeparate;
gl.blendEquationSeparate = function blendEquationSeparate(modeRGB, modeAlpha) {
if (!(arguments.length === 2 && typeof modeRGB === "number" && typeof modeAlpha === "number")) {
throw new TypeError('Expected blendEquationSeparate(number modeRGB, number modeAlpha)');
}
return _blendEquationSeparate.call(this, modeRGB, modeAlpha);
}
var _blendFunc = gl.blendFunc;
gl.blendFunc = function blendFunc(sfactor, dfactor) {
if (!(arguments.length === 2 && typeof sfactor === "number" && typeof dfactor === "number")) {
throw new TypeError('Expected blendFunc(number sfactor, number dfactor)');
}
return _blendFunc.call(this, sfactor, dfactor);
}
var _blendFuncSeparate = gl.blendFuncSeparate;
gl.blendFuncSeparate = function blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha) {
if (!(arguments.length === 4 && typeof srcRGB === "number" && typeof dstRGB === "number" && typeof srcAlpha === "number" && typeof dstAlpha === "number")) {
throw new TypeError('Expected blendFuncSeparate(number srcRGB, number dstRGB, number srcAlpha, number dstAlpha)');
}
return _blendFuncSeparate.call(this, srcRGB, dstRGB, srcAlpha, dstAlpha);
}
var _bufferData = gl.bufferData;
gl.bufferData = function bufferData(target, data, usage) {
if (!(arguments.length === 3 && typeof target === "number" &&
(typeof data === "object" || typeof data === "number") && typeof usage === "number")) {
throw new TypeError('Expected bufferData(number target, ArrayBuffer data, number usage) or bufferData(number target, number size, number usage)');
}
return _bufferData.call(this, target, data, usage);
}
var _bufferSubData = gl.bufferSubData;
gl.bufferSubData = function bufferSubData(target, offset, data) {
if (!(arguments.length === 3 && typeof target === "number" && typeof offset === "number" && typeof data === "object")) {
throw new TypeError('Expected bufferSubData(number target, number offset, ArrayBuffer data)');
}
return _bufferSubData.call(this, target, offset, data);
}
var _checkFramebufferStatus = gl.checkFramebufferStatus;
gl.checkFramebufferStatus = function checkFramebufferStatus(target) {
if (!(arguments.length === 1 && typeof target === "number")) {
throw new TypeError('Expected checkFramebufferStatus(number target)');
}
return _checkFramebufferStatus.call(this, target);
}
var _clear = gl.clear;
gl.clear = function clear(mask) {
if (!(arguments.length === 1 && typeof mask === "number")) {
throw new TypeError('Expected clear(number mask)');
}
return _clear.call(this, mask);
}
var _clearColor = gl.clearColor;
gl.clearColor = function clearColor(red, green, blue, alpha) {
if (!(arguments.length === 4 && typeof red === "number" && typeof green === "number" && typeof blue === "number" && typeof alpha === "number")) {
throw new TypeError('Expected clearColor(number red, number green, number blue, number alpha)');
}
return _clearColor.call(this, red, green, blue, alpha);
}
var _clearDepth = gl.clearDepth;
gl.clearDepth = function clearDepth(depth) {
if (!(arguments.length === 1 && typeof depth === "number")) {
throw new TypeError('Expected clearDepth(number depth)');
}
return _clearDepth.call(this, depth);
}
var _clearStencil = gl.clearStencil;
gl.clearStencil = function clearStencil(s) {
if (!(arguments.length === 1 && typeof s === "number")) {
throw new TypeError('Expected clearStencil(number s)');
}
return _clearStencil.call(this, s);
}
var _colorMask = gl.colorMask;
gl.colorMask = function colorMask(red, green, blue, alpha) {
if (!(arguments.length === 4 && typeof red === "boolean" && typeof green === "boolean" && typeof blue === "boolean" && typeof alpha === "boolean")) {
throw new TypeError('Expected colorMask(boolean red, boolean green, boolean blue, boolean alpha)');
}
return _colorMask.call(this, red, green, blue, alpha);
}
var _compileShader = gl.compileShader;
gl.compileShader = function compileShader(shader) {
if (!(arguments.length === 1 && (shader === null || shader instanceof gl.WebGLShader))) {
throw new TypeError('Expected compileShader(WebGLShader shader)');
}
return _compileShader.call(this, shader ? shader._ : 0);
}
var _copyTexImage2D = gl.copyTexImage2D;
gl.copyTexImage2D = function copyTexImage2D(target, level, internalformat, x, y, width, height, border) {
if (!(arguments.length === 8 && typeof target === "number" && typeof level === "number" && typeof internalformat === "number" && typeof x === "number" && typeof y === "number" && typeof width === "number" && typeof height === "number" && typeof border === "number")) {
throw new TypeError('Expected copyTexImage2D(number target, number level, number internalformat, number x, number y, number width, number height, number border)');
}
return _copyTexImage2D.call(this, target, level, internalformat, x, y, width, height, border);
}
var _copyTexSubImage2D = gl.copyTexSubImage2D;
gl.copyTexSubImage2D = function copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height) {
if (!(arguments.length === 8 && typeof target === "number" && typeof level === "number" && typeof xoffset === "number" && typeof yoffset === "number" && typeof x === "number" && typeof y === "number" && typeof width === "number" && typeof height === "number")) {
throw new TypeError('Expected copyTexSubImage2D(number target, number level, number xoffset, number yoffset, number x, number y, number width, number height)');
}
return _copyTexSubImage2D.call(this, target, level, xoffset, yoffset, x, y, width, height);
}
var _createBuffer = gl.createBuffer;
gl.createBuffer = function createBuffer() {
if (!(arguments.length === 0)) {
throw new TypeError('Expected createBuffer()');
}
return new gl.WebGLBuffer(_createBuffer.call(this));
}
var _createFramebuffer = gl.createFramebuffer;
gl.createFramebuffer = function () {
if (!(arguments.length === 0)) {
throw new TypeError('Expected createFramebuffer()');
}
return new gl.WebGLFramebuffer(_createFramebuffer.call(this));
}
var _createProgram = gl.createProgram;
gl.createProgram = function createProgram() {
if (!(arguments.length === 0)) {
throw new TypeError('Expected createProgram()');
}
return new gl.WebGLProgram(_createProgram.call(this));
}
var _createRenderbuffer = gl.createRenderbuffer;
gl.createRenderbuffer = function createRenderbuffer() {
if (!(arguments.length === 0)) {
throw new TypeError('Expected createRenderbuffer()');
}
return new gl.WebGLRenderbuffer(_createRenderbuffer.call(this));
}
var _createShader = gl.createShader;
gl.createShader = function createShader(type) {
if (!(arguments.length === 1 && typeof type === "number")) {
throw new TypeError('Expected createShader(number type)');
}
return new gl.WebGLShader(_createShader.call(this, type));
}
var _createTexture = gl.createTexture;
gl.createTexture = function createTexture() {
if (!(arguments.length === 0)) {
throw new TypeError('Expected createTexture()');
}
return new gl.WebGLTexture(_createTexture.call(this));
}
var _cullFace = gl.cullFace;
gl.cullFace = function cullFace(mode) {
if (!(arguments.length === 1 && typeof mode === "number")) {
throw new TypeError('Expected cullFace(number mode)');
}
return _cullFace.call(this, mode);
}
var _deleteBuffer = gl.deleteBuffer;
gl.deleteBuffer = function deleteBuffer(buffer) {
if (!(arguments.length === 1 && (buffer === null || buffer instanceof gl.WebGLBuffer))) {
throw new TypeError('Expected deleteBuffer(WebGLBuffer buffer)');
}
return _deleteBuffer.call(this, buffer ? buffer._ : 0);
}
var _deleteFramebuffer = gl.deleteFramebuffer;
gl.deleteFramebuffer = function deleteFramebuffer(framebuffer) {
if (!(arguments.length === 1 && (framebuffer === null || framebuffer instanceof gl.WebGLFramebuffer))) {
throw new TypeError('Expected deleteFramebuffer(WebGLFramebuffer framebuffer)');
}
return _deleteFramebuffer.call(this, framebuffer ? framebuffer._ : 0);
}
var _deleteProgram = gl.deleteProgram;
gl.deleteProgram = function deleteProgram(program) {
if (!(arguments.length === 1 && (program === null || program instanceof gl.WebGLProgram))) {
throw new TypeError('Expected deleteProgram(WebGLProgram program)');
}
return _deleteProgram.call(this, program ? program._ : 0);
}
var _deleteRenderbuffer = gl.deleteRenderbuffer;
gl.deleteRenderbuffer = function deleteRenderbuffer(renderbuffer) {
if (!(arguments.length === 1 && (renderbuffer === null || renderbuffer instanceof gl.WebGLRenderbuffer))) {
throw new TypeError('Expected deleteRenderbuffer(WebGLRenderbuffer renderbuffer)');
}
return _deleteRenderbuffer.call(this, renderbuffer ? renderbuffer._ : 0);
}
var _deleteShader = gl.deleteShader;
gl.deleteShader = function deleteShader(shader) {
if (!(arguments.length === 1 && (shader === null || shader instanceof gl.WebGLShader))) {
throw new TypeError('Expected deleteShader(WebGLShader shader)');
}
return _deleteShader.call(this, shader ? shader._ : 0);
}
var _deleteTexture = gl.deleteTexture;
gl.deleteTexture = function deleteTexture(texture) {
if (!(arguments.length === 1 && (texture === null || texture instanceof gl.WebGLTexture))) {
throw new TypeError('Expected deleteTexture(WebGLTexture texture)');
}
return _deleteTexture.call(this, texture ? texture._ : 0);
}
var _depthFunc = gl.depthFunc;
gl.depthFunc = function depthFunc(func) {
if (!(arguments.length === 1 && typeof func === "number")) {
throw new TypeError('Expected depthFunc(number func)');
}
return _depthFunc.call(this, func);
}
var _depthMask = gl.depthMask;
gl.depthMask = function depthMask(flag) {
if (!(arguments.length === 1 && typeof flag === "boolean")) {
throw new TypeError('Expected depthMask(boolean flag)');
}
return _depthMask.call(this, flag);
}
var _depthRange = gl.depthRange;
gl.depthRange = function depthRange(zNear, zFar) {
if (!(arguments.length === 2 && typeof zNear === "number" && typeof zFar === "number")) {
throw new TypeError('Expected depthRange(number zNear, number zFar)');
}
return _depthRange.call(this, zNear, zFar);
}
var _detachShader = gl.detachShader;
gl.detachShader = function detachShader(program, shader) {
if (!(arguments.length === 2 && (program === null || program instanceof gl.WebGLProgram) && (shader === null || shader instanceof gl.WebGLShader))) {
throw new TypeError('Expected detachShader(WebGLProgram program, WebGLShader shader)');
}
return _detachShader.call(this, program ? program._ : 0, shader ? shader._ : 0);
}
var _disable = gl.disable;
gl.disable = function disable(cap) {
if (!(arguments.length === 1 && typeof cap === "number")) {
throw new TypeError('Expected disable(number cap)');
}
return _disable.call(this, cap);
}
var _disableVertexAttribArray = gl.disableVertexAttribArray;
gl.disableVertexAttribArray = function disableVertexAttribArray(index) {
if (!(arguments.length === 1 && typeof index === "number")) {
throw new TypeError('Expected disableVertexAttribArray(number index)');
}
return _disableVertexAttribArray.call(this, index);
}
var _drawArrays = gl.drawArrays;
gl.drawArrays = function drawArrays(mode, first, count) {
if (!(arguments.length === 3 && typeof mode === "number" && typeof first === "number" && typeof count === "number")) {
throw new TypeError('Expected drawArrays(number mode, number first, number count)');
}
return _drawArrays.call(this, mode, first, count);
}
var _drawElements = gl.drawElements;
gl.drawElements = function drawElements(mode, count, type, offset) {
if (!(arguments.length === 4 && typeof mode === "number" && typeof count === "number" && typeof type === "number" && typeof offset === "number")) {
throw new TypeError('Expected drawElements(number mode, number count, number type, number offset)');
}
return _drawElements.call(this, mode, count, type, offset);
}
var _enable = gl.enable;
gl.enable = function enable(cap) {
if (!(arguments.length === 1 && typeof cap === "number")) {
throw new TypeError('Expected enable(number cap)');
}
return _enable.call(this, cap);
}
var _enableVertexAttribArray = gl.enableVertexAttribArray;
gl.enableVertexAttribArray = function enableVertexAttribArray(index) {
if (!(arguments.length === 1 && typeof index === "number")) {
throw new TypeError('Expected enableVertexAttribArray(number index)');
}
return _enableVertexAttribArray.call(this, index);
}
var _finish = gl.finish;
gl.finish = function finish() {
if (!(arguments.length === 0)) {
throw new TypeError('Expected finish()');
}
return _finish.call(this);
}
var _flush = gl.flush;
gl.flush = function flush() {
if (!(arguments.length === 0)) {
throw new TypeError('Expected flush()');
}
return _flush.call(this);
}
var _framebufferRenderbuffer = gl.framebufferRenderbuffer;
gl.framebufferRenderbuffer = function framebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer) {
if (!(arguments.length === 4 && typeof target === "number" && typeof attachment === "number" && typeof renderbuffertarget === "number" && (renderbuffer === null || renderbuffer instanceof gl.WebGLRenderbuffer))) {
throw new TypeError('Expected framebufferRenderbuffer(number target, number attachment, number renderbuffertarget, WebGLRenderbuffer renderbuffer)');
}
return _framebufferRenderbuffer.call(this, target, attachment, renderbuffertarget, renderbuffer ? renderbuffer._ : 0);
}
var _framebufferTexture2D = gl.framebufferTexture2D;
gl.framebufferTexture2D = function framebufferTexture2D(target, attachment, textarget, texture, level) {
if (!(arguments.length === 5 && typeof target === "number" && typeof attachment === "number" && typeof textarget === "number" && (texture === null || texture instanceof gl.WebGLTexture) && typeof level === "number")) {
throw new TypeError('Expected framebufferTexture2D(number target, number attachment, number textarget, WebGLTexture texture, number level)');
}
return _framebufferTexture2D.call(this, target, attachment, textarget, texture ? texture._ : 0, level);
}
var _frontFace = gl.frontFace;
gl.frontFace = function frontFace(mode) {
if (!(arguments.length === 1 && typeof mode === "number")) {
throw new TypeError('Expected frontFace(number mode)');
}
return _frontFace.call(this, mode);
}
var _generateMipmap = gl.generateMipmap;
gl.generateMipmap = function generateMipmap(target) {
if (!(arguments.length === 1 && typeof target === "number")) {
throw new TypeError('Expected generateMipmap(number target)');
}
return _generateMipmap.call(this, target);
}
var _getActiveAttrib = gl.getActiveAttrib;
gl.getActiveAttrib = function getActiveAttrib(program, index) {
if (!(arguments.length === 2 && (program === null || program instanceof gl.WebGLProgram) && typeof index === "number")) {
throw new TypeError('Expected getActiveAttrib(WebGLProgram program, number index)');
}
return new gl.WebGLActiveInfo(_getActiveAttrib.call(this, program ? program._ : 0, index));
}
var _getActiveUniform = gl.getActiveUniform;
gl.getActiveUniform = function getActiveUniform(program, index) {
if (!(arguments.length === 2 && (program === null || program instanceof gl.WebGLProgram) && typeof index === "number")) {
throw new TypeError('Expected getActiveUniform(WebGLProgram program, number index)');
}
return new gl.WebGLActiveInfo(_getActiveUniform.call(this, program ? program._ : 0, index));
}
var _getAttachedShaders = gl.getAttachedShaders;
gl.getAttachedShaders = function getAttachedShaders(program) {
if (!(arguments.length === 1 && (program === null || program instanceof gl.WebGLProgram))) {
throw new TypeError('Expected getAttachedShaders(WebGLProgram program)');
}
return _getAttachedShaders.call(this, program ? program._ : 0);
}
var _getAttribLocation = gl.getAttribLocation;
gl.getAttribLocation = function getAttribLocation(program, name) {
if (!(arguments.length === 2 && (program === null || program instanceof gl.WebGLProgram) && typeof name === "string")) {
throw new TypeError('Expected getAttribLocation(WebGLProgram program, string name)');
}
return _getAttribLocation.call(this, program ? program._ : 0, name);
}
var _getParameter = gl.getParameter;
gl.getParameter = function getParameter(pname) {
if (!(arguments.length === 1 && typeof pname === "number")) {
throw new TypeError('Expected getParameter(number pname)');
}
return _getParameter.call(this, pname);
}
var _getBufferParameter = gl.getBufferParameter;
gl.getBufferParameter = function getBufferParameter(target, pname) {
if (!(arguments.length === 2 && typeof target === "number" && typeof pname === "number")) {
throw new TypeError('Expected getBufferParameter(number target, number pname)');
}
return _getBufferParameter.call(this, target, pname);
}
var _getError = gl.getError;
gl.getError = function getError() {
if (!(arguments.length === 0)) {
throw new TypeError('Expected getError()');
}
return _getError.call(this);
}
var _getFramebufferAttachmentParameter = gl.getFramebufferAttachmentParameter;
gl.getFramebufferAttachmentParameter = function getFramebufferAttachmentParameter(target, attachment, pname) {
if (!(arguments.length === 3 && typeof target === "number" && typeof attachment === "number" && typeof pname === "number")) {
throw new TypeError('Expected getFramebufferAttachmentParameter(number target, number attachment, number pname)');
}
return _getFramebufferAttachmentParameter.call(this, target, attachment, pname);
}
var _getProgramParameter = gl.getProgramParameter;
gl.getProgramParameter = function getProgramParameter(program, pname) {
if (!(arguments.length === 2 && (program === null || program instanceof gl.WebGLProgram) && typeof pname === "number")) {
throw new TypeError('Expected getProgramParameter(WebGLProgram program, number pname)');
}
return _getProgramParameter.call(this, program ? program._ : 0, pname);
}
var _getProgramInfoLog = gl.getProgramInfoLog;
gl.getProgramInfoLog = function getProgramInfoLog(program) {
if (!(arguments.length === 1 && (program === null || program instanceof gl.WebGLProgram))) {
throw new TypeError('Expected getProgramInfoLog(WebGLProgram program)');
}
return _getProgramInfoLog.call(this, program ? program._ : 0);
}
var _getRenderbufferParameter = gl.getRenderbufferParameter;
gl.getRenderbufferParameter = function getRenderbufferParameter(target, pname) {
if (!(arguments.length === 2 && typeof target === "number" && typeof pname === "number")) {
throw new TypeError('Expected getRenderbufferParameter(number target, number pname)');
}
return _getRenderbufferParameter.call(this, target, pname);
}
var _getShaderParameter = gl.getShaderParameter;
gl.getShaderParameter = function getShaderParameter(shader, pname) {
if (!(arguments.length === 2 && (shader === null || shader instanceof gl.WebGLShader) && typeof pname === "number")) {
throw new TypeError('Expected getShaderParameter(WebGLShader shader, number pname)');
}
return _getShaderParameter.call(this, shader ? shader._ : 0, pname);
}
var _getShaderInfoLog = gl.getShaderInfoLog;
gl.getShaderInfoLog = function getShaderInfoLog(shader) {
if (!(arguments.length === 1 && (shader === null || shader instanceof gl.WebGLShader))) {
throw new TypeError('Expected getShaderInfoLog(WebGLShader shader)');
}
return _getShaderInfoLog.call(this, shader ? shader._ : 0);
}
var _getShaderSource = gl.getShaderSource;
gl.getShaderSource = function getShaderSource(shader) {
if (!(arguments.length === 1 && (shader === null || shader instanceof gl.WebGLShader))) {
throw new TypeError('Expected getShaderSource(WebGLShader shader)');
}
return _getShaderSource.call(this, shader ? shader._ : 0);
}
var _getTexParameter = gl.getTexParameter;
gl.getTexParameter = function getTexParameter(target, pname) {
if (!(arguments.length === 2 && typeof target === "number" && typeof pname === "number")) {
throw new TypeError('Expected getTexParameter(number target, number pname)');
}
return _getTexParameter.call(this, target, pname);
}
var _getUniform = gl.getUniform;
gl.getUniform = function getUniform(program, location) {
if (!(arguments.length === 2 && (program === null || program instanceof gl.WebGLProgram) && (location === null || location instanceof gl.WebGLUniformLocation))) {
throw new TypeError('Expected getUniform(WebGLProgram program, WebGLUniformLocation location)');
}
return _getUniform.call(this, program ? program._ : 0, location ? location._ : 0);
}
var _getUniformLocation = gl.getUniformLocation;
gl.getUniformLocation = function getUniformLocation(program, name) {
if (!(arguments.length === 2 && (program === null || program instanceof gl.WebGLProgram) && typeof name === "string")) {
throw new TypeError('Expected getUniformLocation(WebGLProgram program, string name)');
}
return new gl.WebGLUniformLocation(_getUniformLocation.call(this, program ? program._ : 0, name));
}
var _getVertexAttrib = gl.getVertexAttrib;
gl.getVertexAttrib = function getVertexAttrib(index, pname) {
if (!(arguments.length === 2 && typeof index === "number" && typeof pname === "number")) {
throw new TypeError('Expected getVertexAttrib(number index, number pname)');
}
return _getVertexAttrib.call(this, index, pname);
}
var _getVertexAttribOffset = gl.getVertexAttribOffset;
gl.getVertexAttribOffset = function getVertexAttribOffset(index, pname) {
if (!(arguments.length === 2 && typeof index === "number" && typeof pname === "number")) {
throw new TypeError('Expected getVertexAttribOffset(number index, number pname)');
}
if(pname === gl.CURRENT_VERTEX_ATTRIB) {
var buf=_getVertexAttribOffset(index, pname);
return new Float32Array(buf);
}
return _getVertexAttribOffset.call(this, index, pname);
}
var _hint = gl.hint;
gl.hint = function hint(target, mode) {
if (!(arguments.length === 2 && typeof target === "number" && typeof mode === "number")) {
throw new TypeError('Expected hint(number target, number mode)');
}
return _hint.call(this, target, mode);
}
var _isBuffer = gl.isBuffer;
gl.isBuffer = function isBuffer(buffer) {
if (!(arguments.length === 1 && (buffer === null || buffer instanceof gl.WebGLBuffer))) {
throw new TypeError('Expected isBuffer(WebGLBuffer buffer)');
}
return _isBuffer.call(this, buffer ? buffer._ : 0);
}
var _isEnabled = gl.isEnabled;
gl.isEnabled = function isEnabled(cap) {
if (!(arguments.length === 1 && typeof cap === "number")) {
throw new TypeError('Expected isEnabled(number cap)');
}
return _isEnabled.call(this, cap);
}
var _isFramebuffer = gl.isFramebuffer;
gl.isFramebuffer = function isFramebuffer(framebuffer) {
if (!(arguments.length === 1 && (framebuffer === null || framebuffer instanceof gl.WebGLFramebuffer))) {
throw new TypeError('Expected isFramebuffer(WebGLFramebuffer framebuffer)');
}
return _isFramebuffer.call(this, framebuffer ? framebuffer._ : 0);
}
var _isProgram = gl.isProgram;
gl.isProgram = function isProgram(program) {
if (!(arguments.length === 1 && (program === null || program instanceof gl.WebGLProgram))) {
throw new TypeError('Expected isProgram(WebGLProgram program)');
}
return _isProgram.call(this, program ? program._ : 0);
}
var _isRenderbuffer = gl.isRenderbuffer;
gl.isRenderbuffer = function isRenderbuffer(renderbuffer) {
if (!(arguments.length === 1 && (renderbuffer === null || renderbuffer instanceof gl.WebGLRenderbuffer))) {
throw new TypeError('Expected isRenderbuffer(WebGLRenderbuffer renderbuffer)');
}
return _isRenderbuffer.call(this, renderbuffer ? renderbuffer._ : 0);
}
var _isShader = gl.isShader;
gl.isShader = function isShader(shader) {
if (!(arguments.length === 1 && (shader === null || shader instanceof gl.WebGLShader))) {
throw new TypeError('Expected isShader(WebGLShader shader)');
}
return _isShader.call(this, shader ? shader._ : 0);
}
var _isTexture = gl.isTexture;
gl.isTexture = function isTexture(texture) {
if (!(arguments.length === 1 && (texture === null || texture instanceof gl.WebGLTexture))) {
throw new TypeError('Expected isTexture(WebGLTexture texture)');
}
return _isTexture.call(this, texture ? texture._ : 0);
}
var _lineWidth = gl.lineWidth;
gl.lineWidth = function lineWidth(width) {
if (!(arguments.length === 1 && typeof width === "number")) {
throw new TypeError('Expected lineWidth(number width)');
}
return _lineWidth.call(this, width);
}
var _linkProgram = gl.linkProgram;
gl.linkProgram = function linkProgram(program) {
if (!(arguments.length === 1 && (program === null || program instanceof gl.WebGLProgram))) {
throw new TypeError('Expected linkProgram(WebGLProgram program)');
}
return _linkProgram.call(this, program ? program._ : 0);
}
var _pixelStorei = gl.pixelStorei;
gl.pixelStorei = function pixelStorei(pname, param) {
if (!(arguments.length === 2 && typeof pname === "number" && (typeof param === "number") || typeof param === "boolean")) {
throw new TypeError('Expected pixelStorei(number pname, number param)');
}
if(typeof param === "boolean")
param= param ? 1 : 0;
return _pixelStorei.call(this, pname, param);
}
var _polygonOffset = gl.polygonOffset;
gl.polygonOffset = function polygonOffset(factor, units) {
if (!(arguments.length === 2 && typeof factor === "number" && typeof units === "number")) {
throw new TypeError('Expected polygonOffset(number factor, number units)');
}
return _polygonOffset.call(this, factor, units);
}
var _readPixels = gl.readPixels;
gl.readPixels = function readPixels(x, y, width, height, format, type, pixels) {
if (!(arguments.length === 7 && typeof x === "number" && typeof y === "number" && typeof width === "number" && typeof height === "number" && typeof format === "number" && typeof type === "number" && typeof pixels === "object")) {
throw new TypeError('Expected readPixels(number x, number y, number width, number height, number format, number type, ArrayBufferView pixels)');
}
return _readPixels.call(this, x, y, width, height, format, type, pixels);
}
var _renderbufferStorage = gl.renderbufferStorage;
gl.renderbufferStorage = function renderbufferStorage(target, internalformat, width, height) {
if (!(arguments.length === 4 && typeof target === "number" && typeof internalformat === "number" && typeof width === "number" && typeof height === "number")) {
throw new TypeError('Expected renderbufferStorage(number target, number internalformat, number width, number height)');
}
return _renderbufferStorage.call(this, target, internalformat, width, height);
}
var _sampleCoverage = gl.sampleCoverage;
gl.sampleCoverage = function sampleCoverage(value, invert) {
if (!(arguments.length === 2 && typeof value === "number" && typeof invert === "boolean")) {
throw new TypeError('Expected sampleCoverage(number value, boolean invert)');
}
return _sampleCoverage.call(this, value, invert);
}
var _scissor = gl.scissor;
gl.scissor = function scissor(x, y, width, height) {
if (!(arguments.length === 4 && typeof x === "number" && typeof y === "number" && typeof width === "number" && typeof height === "number")) {
throw new TypeError('Expected scissor(number x, number y, number width, number height)');
}
return _scissor.call(this, x, y, width, height);
}
var _shaderSource = gl.shaderSource;
gl.shaderSource = function shaderSource(shader, source) {
if (!(arguments.length === 2 && (shader === null || shader instanceof gl.WebGLShader) && typeof source === "string")) {
throw new TypeError('Expected shaderSource(WebGLShader shader, string source)');
}
return _shaderSource.call(this, shader ? shader._ : 0, source);
}
var _stencilFunc = gl.stencilFunc;
gl.stencilFunc = function stencilFunc(func, ref, mask) {
if (!(arguments.length === 3 && typeof func === "number" && typeof ref === "number" && typeof mask === "number")) {
throw new TypeError('Expected stencilFunc(number func, number ref, number mask)');
}
return _stencilFunc.call(this, func, ref, mask);
}
var _stencilFuncSeparate = gl.stencilFuncSeparate;
gl.stencilFuncSeparate = function stencilFuncSeparate(face, func, ref, mask) {
if (!(arguments.length === 4 && typeof face === "number" && typeof func === "number" && typeof ref === "number" && typeof mask === "number")) {
throw new TypeError('Expected stencilFuncSeparate(number face, number func, number ref, number mask)');
}
return _stencilFuncSeparate.call(this, face, func, ref, mask);
}
var _stencilMask = gl.stencilMask;
gl.stencilMask = function stencilMask(mask) {
if (!(arguments.length === 1 && typeof mask === "number")) {
throw new TypeError('Expected stencilMask(number mask)');
}
return _stencilMask.call(this, mask);
}
var _stencilMaskSeparate = gl.stencilMaskSeparate;
gl.stencilMaskSeparate = function stencilMaskSeparate(face, mask) {
if (!(arguments.length === 2 && typeof face === "number" && typeof mask === "number")) {
throw new TypeError('Expected stencilMaskSeparate(number face, number mask)');
}
return _stencilMaskSeparate.call(this, face, mask);
}
var _stencilOp = gl.stencilOp;
gl.stencilOp = function stencilOp(fail, zfail, zpass) {
if (!(arguments.length === 3 && typeof fail === "number" && typeof zfail === "number" && typeof zpass === "number")) {
throw new TypeError('Expected stencilOp(number fail, number zfail, number zpass)');
}
return _stencilOp.call(this, fail, zfail, zpass);
}
var _stencilOpSeparate = gl.stencilOpSeparate;
gl.stencilOpSeparate = function stencilOpSeparate(face, fail, zfail, zpass) {
if (!(arguments.length === 4 && typeof face === "number" && typeof fail === "number" && typeof zfail === "number" && typeof zpass === "number")) {
throw new TypeError('Expected stencilOpSeparate(number face, number fail, number zfail, number zpass)');
}
return _stencilOpSeparate.call(this, face, fail, zfail, zpass);
}
var _texImage2D = gl.texImage2D;
gl.texImage2D = function texImage2D(target, level, internalformat, width, height, border, format, type, pixels) {
if(!(arguments.length == 9 || arguments.length == 6)) {
throw new TypeError('Expected texImage2D(number target, number level, number internalformat, number width, number height, number border, number format, number type, ArrayBufferView pixels) \
or texImage2D(number target, number level, number internalformat, number format, number type, Image pixels)');
}
if (arguments.length == 6) {
// width is now format, height is now type, and border is now pixels
if(!(
typeof target === "number" &&
typeof level === "number" && typeof internalformat === "number" &&
typeof width === "number" && typeof height === "number" &&
typeof border === "object")) {
throw new TypeError('Expected texImage2D(number target, number level, number internalformat, number format, number type, Image pixels)');
}
pixels=border;
type=height;
format=width;
return _texImage2D.call(this, target, level, internalformat, pixels.width, pixels.height, 0, format, type, new Buffer(pixels.data));
}
else if (arguments.length == 9) {
if(!(typeof target === "number" &&
typeof level === "number" && typeof internalformat === "number" &&
typeof width === "number" && typeof height === "number" && typeof border === "number" &&
typeof format === "number" && typeof type === "number" &&
(pixels==null || typeof pixels === "object"))) {
throw new TypeError('Expected texImage2D(number target, number level, number internalformat, number width, number height, number border, number format, number type, ArrayBufferView pixels)');
}
return _texImage2D.call(this, target, level, internalformat, width, height, border, format, type, pixels);
}
}
var _texParameterf = gl.texParameterf;
gl.texParameterf = function texParameterf(target, pname, param) {
if (!(arguments.length === 3 && typeof target === "number" && typeof pname === "number" && typeof param === "number")) {
throw new TypeError('Expected texParameterf(number target, number pname, number param)');
}
return _texParameterf.call(this, target, pname, param);
}
var _texParameteri = gl.texParameteri;
gl.texParameteri = function texParameteri(target, pname, param) {
if (!(arguments.length === 3 && typeof target === "number" && typeof pname === "number" && typeof param === "number")) {
throw new TypeError('Expected texParameteri(number target, number pname, number param)');
}
return _texParameteri.call(this, target, pname, param);
}
var _texSubImage2D = gl.texSubImage2D;
gl.texSubImage2D = function texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels) {
if (!(arguments.length === 9 && typeof target === "number" && typeof level === "number" &&
typeof xoffset === "number" && typeof yoffset === "number" &&
typeof width === "number" && typeof height === "number" &&
typeof format === "number" && typeof type === "number" &&
(pixels==null || typeof pixels === "object"))) {
throw new TypeError('Expected texSubImage2D(number target, number level, number xoffset, number yoffset, number width, number height, number format, number type, ArrayBufferView pixels)');
}
return _texSubImage2D.call(this, target, level, xoffset, yoffset, width, height, format, type, pixels);
}
var _uniform1f = gl.uniform1f;
gl.uniform1f = function uniform1f(location, x) {
if (!(arguments.length === 2 && (location === null || location instanceof gl.WebGLUniformLocation) && (typeof x === "number" || typeof x === "boolean"))) {
throw new TypeError('Expected uniform1f(WebGLUniformLocation location, number x)');
}
return _uniform1f.call(this, location ? location._ : 0, x);
}
var _uniform1fv = gl.uniform1fv;
gl.uniform1fv = function uniform1fv(location, v) {
if (!(arguments.length === 2 && (location === null || location instanceof gl.WebGLUniformLocation) && typeof v === "object")) {
throw new TypeError('Expected uniform1fv(WebGLUniformLocation location, FloatArray v)');
}
return _uniform1fv.call(this, location ? location._ : 0, v);
}
var _uniform1i = gl.uniform1i;
gl.uniform1i = function uniform1i(location, x) {
if (!(arguments.length === 2 && (location === null || location instanceof gl.WebGLUniformLocation) && (typeof x === "number" || typeof x ==="boolean"))) {
throw new TypeError('Expected uniform1i(WebGLUniformLocation location, number x)');
}
if(typeof x === "boolean")
x= x ? 1 : 0;
return _uniform1i.call(this, location ? location._ : 0, x);
}
var _uniform1iv = gl.uniform1iv;
gl.uniform1iv = function uniform1iv(location, v) {
if (!(arguments.length === 2 && (location === null || location instanceof gl.WebGLUniformLocation) && typeof v === "object")) {
throw new TypeError('Expected uniform1iv(WebGLUniformLocation location, Int32Array v)');
}
return _uniform1iv.call(this, location ? location._ : 0, v);
}
var _uniform2f = gl.uniform2f;
gl.uniform2f = function uniform2f(location, x, y) {
if (!(arguments.length === 3 && (location === null || location instanceof gl.WebGLUniformLocation) && typeof x === "number" && typeof y === "number")) {
throw new TypeError('Expected uniform2f(WebGLUniformLocation location, number x, number y)');
}
return _uniform2f.call(this, location ? location._ : 0, x, y);
}
var _uniform2fv = gl.uniform2fv;
gl.uniform2fv = function uniform2fv(location, v) {
if (!(arguments.length === 2 && (location === null || location instanceof gl.WebGLUniformLocation) && typeof v === "object")) {
throw new TypeError('Expected uniform2fv(WebGLUniformLocation location, FloatArray v)');
}
return _uniform2fv.call(this, location ? location._ : 0, v);
}
var _uniform2i = gl.uniform2i;
gl.uniform2i = function uniform2i(location, x, y) {
if (!(arguments.length === 3 && (location === null || location instanceof gl.WebGLUniformLocation) && typeof x === "number" && typeof y === "number")) {
throw new TypeError('Expected uniform2i(WebGLUniformLocation location, number x, number y)');
}
return _uniform2i.call(this, location ? location._ : 0, x, y);
}
var _uniform2iv = gl.uniform2iv;
gl.uniform2iv = function uniform2iv(location, v) {
if (!(arguments.length === 2 && (location === null || location instanceof gl.WebGLUniformLocation) && typeof v === "object")) {
throw new TypeError('Expected uniform2iv(WebGLUniformLocation location, Int32Array v)');
}
return _uniform2iv.call(this, location ? location._ : 0, v);
}
var _uniform3f = gl.uniform3f;
gl.uniform3f = function uniform3f(location, x, y, z) {
if (!(arguments.length === 4 && (location === null || location instanceof gl.WebGLUniformLocation) && typeof x === "number" && typeof y === "number" && typeof z === "number")) {
throw new TypeError('Expected uniform3f(WebGLUniformLocation location, number x, number y, number z)');
}
return _uniform3f.call(this, location ? location._ : 0, x, y, z);
}
var _uniform3fv = gl.uniform3fv;
gl.uniform3fv = function uniform3fv(location, v) {
if (!(arguments.length === 2 && (location === null || location instanceof gl.WebGLUniformLocation) && typeof v === "object")) {
throw new TypeError('Expected uniform3fv(WebGLUniformLocation location, FloatArray v)');
}
return _uniform3fv.call(this, location ? location._ : 0, v);
}
var _uniform3i = gl.uniform3i;
gl.uniform3i = function uniform3i(location, x, y, z) {
if (!(arguments.length === 4 && (location === null || location instanceof gl.WebGLUniformLocation) && typeof x === "number" && typeof y === "number" && typeof z === "number")) {
throw new TypeError('Expected uniform3i(WebGLUniformLocation location, number x, number y, number z)');
}
return _uniform3i.call(this, location ? location._ : 0, x, y, z);
}
var _uniform3iv = gl.uniform3iv;
gl.uniform3iv = function uniform3iv(location, x) {
if (!(arguments.length === 2 && (location === null || location instanceof gl.WebGLUniformLocation) && typeof x === "object")) {
throw new TypeError('Expected uniform3iv(WebGLUniformLocation location, Int32Array x)');
}
return _uniform3iv.call(this, location ? location._ : 0, x);
}
var _uniform4f = gl.uniform4f;
gl.uniform4f = function uniform4f(location, x, y, z, w) {
if (!(arguments.length === 5 && (location === null || location instanceof gl.WebGLUniformLocation) && typeof x === "number" && typeof y === "number" && typeof z === "number" && typeof w === "number")) {
throw new TypeError('Expected uniform4f(WebGLUniformLocation location, number x, number y, number z, number w)');
}
return _uniform4f.call(this, location ? location._ : 0, x, y, z, w);
}
var _uniform4fv = gl.uniform4fv;
gl.uniform4fv = function uniform4fv(location, v) {
if (!(arguments.length === 2 && (location === null || location instanceof gl.WebGLUniformLocation) && typeof v === "object")) {
throw new TypeError('Expected uniform4fv(WebGLUniformLocation location, FloatArray v)');
}
return _uniform4fv.call(this, location ? location._ : 0, v);
}
var _uniform4i = gl.uniform4i;
gl.uniform4i = function uniform4i(location, x, y, z, w) {
if (!(arguments.length === 5 && (location === null || location instanceof gl.WebGLUniformLocation) && typeof x === "number" && typeof y === "number" && typeof z === "number" && typeof w === "number")) {
throw new TypeError('Expected uniform4i(WebGLUniformLocation location, number x, number y, number z, number w)');
}
return _uniform4i.call(this, location ? location._ : 0, x, y, z, w);
}
var _uniform4iv = gl.uniform4iv;
gl.uniform4iv = function uniform4iv(location, x) {
if (!(arguments.length === 2 && (location === null || location instanceof gl.WebGLUniformLocation) && typeof x === "object")) {
throw new TypeError('Expected uniform4iv(WebGLUniformLocation location, Int32Array x)');
}
return _uniform4iv.call(this, location ? location._ : 0, x);
}
var _uniformMatrix2fv = gl.uniformMatrix2fv;
gl.uniformMatrix2fv = function uniformMatrix2fv(location, transpose, value) {
if (!(arguments.length === 3 && (location === null || location instanceof gl.WebGLUniformLocation) && typeof transpose === "boolean" && typeof value === "object")) {
throw new TypeError('Expected uniformMatrix2fv(WebGLUniformLocation location, boolean transpose, FloatArray value)');
}
return _uniformMatrix2fv.call(this, location ? location._ : 0, transpose, value);
}
var _uniformMatrix3fv = gl.uniformMatrix3fv;
gl.uniformMatrix3fv = function uniformMatrix3fv(location, transpose, value) {
if (!(arguments.length === 3 && (location === null || location instanceof gl.WebGLUniformLocation) && typeof transpose === "boolean" && typeof value === "object")) {
throw new TypeError('Expected uniformMatrix3fv(WebGLUniformLocation location, boolean transpose, FloatArray value)');
}
return _uniformMatrix3fv.call(this, location ? location._ : 0, transpose, value);
}
var _uniformMatrix4fv = gl.uniformMatrix4fv;
gl.uniformMatrix4fv = function uniformMatrix4fv(location, transpose, value) {
if (!(arguments.length === 3 && (location === null || location instanceof gl.WebGLUniformLocation) && typeof transpose === "boolean" && typeof value === "object")) {
throw new TypeError('Expected uniformMatrix4fv(WebGLUniformLocation location, boolean transpose, FloatArray value)');
}
return _uniformMatrix4fv.call(this, location ? location._ : 0, transpose, value);
}