1
function headlessCanvas() {
4
getContext: function(which) {
6
case 'experimental-webgl': {
9
DEPTH_BUFFER_BIT : 0x00000100,
10
STENCIL_BUFFER_BIT : 0x00000400,
11
COLOR_BUFFER_BIT : 0x00004000,
19
TRIANGLE_STRIP : 0x0005,
20
TRIANGLE_FAN : 0x0006,
22
/* AlphaFunction (not supported in ES20) */
32
/* BlendingFactorDest */
36
ONE_MINUS_SRC_COLOR : 0x0301,
38
ONE_MINUS_SRC_ALPHA : 0x0303,
40
ONE_MINUS_DST_ALPHA : 0x0305,
42
/* BlendingFactorSrc */
46
ONE_MINUS_DST_COLOR : 0x0307,
47
SRC_ALPHA_SATURATE : 0x0308,
49
/* ONE_MINUS_SRC_ALPHA */
51
/* ONE_MINUS_DST_ALPHA */
53
/* BlendEquationSeparate */
55
BLEND_EQUATION : 0x8009,
56
BLEND_EQUATION_RGB : 0x8009, /* same as BLEND_EQUATION */
57
BLEND_EQUATION_ALPHA : 0x883D,
60
FUNC_SUBTRACT : 0x800A,
61
FUNC_REVERSE_SUBTRACT : 0x800B,
63
/* Separate Blend Functions */
64
BLEND_DST_RGB : 0x80C8,
65
BLEND_SRC_RGB : 0x80C9,
66
BLEND_DST_ALPHA : 0x80CA,
67
BLEND_SRC_ALPHA : 0x80CB,
68
CONSTANT_COLOR : 0x8001,
69
ONE_MINUS_CONSTANT_COLOR : 0x8002,
70
CONSTANT_ALPHA : 0x8003,
71
ONE_MINUS_CONSTANT_ALPHA : 0x8004,
75
ARRAY_BUFFER : 0x8892,
76
ELEMENT_ARRAY_BUFFER : 0x8893,
77
ARRAY_BUFFER_BINDING : 0x8894,
78
ELEMENT_ARRAY_BUFFER_BINDING : 0x8895,
82
DYNAMIC_DRAW : 0x88E8,
85
BUFFER_USAGE : 0x8765,
87
CURRENT_VERTEX_ATTRIB : 0x8626,
92
FRONT_AND_BACK : 0x0408,
109
STENCIL_TEST : 0x0B90,
111
SCISSOR_TEST : 0x0C11,
112
POLYGON_OFFSET_FILL : 0x8037,
113
SAMPLE_ALPHA_TO_COVERAGE : 0x809E,
114
SAMPLE_COVERAGE : 0x80A0,
118
INVALID_ENUM : 0x0500,
119
INVALID_VALUE : 0x0501,
120
INVALID_OPERATION : 0x0502,
121
OUT_OF_MEMORY : 0x0505,
123
/* FrontFaceDirection */
129
ALIASED_POINT_SIZE_RANGE : 0x846D,
130
ALIASED_LINE_WIDTH_RANGE : 0x846E,
131
CULL_FACE_MODE : 0x0B45,
133
DEPTH_RANGE : 0x0B70,
134
DEPTH_WRITEMASK : 0x0B72,
135
DEPTH_CLEAR_VALUE : 0x0B73,
137
STENCIL_CLEAR_VALUE : 0x0B91,
138
STENCIL_FUNC : 0x0B92,
139
STENCIL_FAIL : 0x0B94,
140
STENCIL_PASS_DEPTH_FAIL : 0x0B95,
141
STENCIL_PASS_DEPTH_PASS : 0x0B96,
142
STENCIL_REF : 0x0B97,
143
STENCIL_VALUE_MASK : 0x0B93,
144
STENCIL_WRITEMASK : 0x0B98,
145
STENCIL_BACK_FUNC : 0x8800,
146
STENCIL_BACK_FAIL : 0x8801,
147
STENCIL_BACK_PASS_DEPTH_FAIL : 0x8802,
148
STENCIL_BACK_PASS_DEPTH_PASS : 0x8803,
149
STENCIL_BACK_REF : 0x8CA3,
150
STENCIL_BACK_VALUE_MASK : 0x8CA4,
151
STENCIL_BACK_WRITEMASK : 0x8CA5,
153
SCISSOR_BOX : 0x0C10,
155
COLOR_CLEAR_VALUE : 0x0C22,
156
COLOR_WRITEMASK : 0x0C23,
157
UNPACK_ALIGNMENT : 0x0CF5,
158
PACK_ALIGNMENT : 0x0D05,
159
MAX_TEXTURE_SIZE : 0x0D33,
160
MAX_VIEWPORT_DIMS : 0x0D3A,
161
SUBPIXEL_BITS : 0x0D50,
167
STENCIL_BITS : 0x0D57,
168
POLYGON_OFFSET_UNITS : 0x2A00,
169
/* POLYGON_OFFSET_FILL */
170
POLYGON_OFFSET_FACTOR : 0x8038,
171
TEXTURE_BINDING_2D : 0x8069,
172
SAMPLE_BUFFERS : 0x80A8,
174
SAMPLE_COVERAGE_VALUE : 0x80AA,
175
SAMPLE_COVERAGE_INVERT : 0x80AB,
177
/* GetTextureParameter */
178
/* TEXTURE_MAG_FILTER */
179
/* TEXTURE_MIN_FILTER */
183
COMPRESSED_TEXTURE_FORMATS : 0x86A3,
191
GENERATE_MIPMAP_HINT : 0x8192,
195
UNSIGNED_BYTE : 0x1401,
197
UNSIGNED_SHORT : 0x1403,
199
UNSIGNED_INT : 0x1405,
203
DEPTH_COMPONENT : 0x1902,
208
LUMINANCE_ALPHA : 0x190A,
212
UNSIGNED_SHORT_4_4_4_4 : 0x8033,
213
UNSIGNED_SHORT_5_5_5_1 : 0x8034,
214
UNSIGNED_SHORT_5_6_5 : 0x8363,
217
FRAGMENT_SHADER : 0x8B30,
218
VERTEX_SHADER : 0x8B31,
219
MAX_VERTEX_ATTRIBS : 0x8869,
220
MAX_VERTEX_UNIFORM_VECTORS : 0x8DFB,
221
MAX_VARYING_VECTORS : 0x8DFC,
222
MAX_COMBINED_TEXTURE_IMAGE_UNITS : 0x8B4D,
223
MAX_VERTEX_TEXTURE_IMAGE_UNITS : 0x8B4C,
224
MAX_TEXTURE_IMAGE_UNITS : 0x8872,
225
MAX_FRAGMENT_UNIFORM_VECTORS : 0x8DFD,
226
SHADER_TYPE : 0x8B4F,
227
DELETE_STATUS : 0x8B80,
228
LINK_STATUS : 0x8B82,
229
VALIDATE_STATUS : 0x8B83,
230
ATTACHED_SHADERS : 0x8B85,
231
ACTIVE_UNIFORMS : 0x8B86,
232
ACTIVE_ATTRIBUTES : 0x8B89,
233
SHADING_LANGUAGE_VERSION : 0x8B8C,
234
CURRENT_PROGRAM : 0x8B8D,
236
/* StencilFunction */
261
/* TextureMagFilter */
265
/* TextureMinFilter */
268
NEAREST_MIPMAP_NEAREST : 0x2700,
269
LINEAR_MIPMAP_NEAREST : 0x2701,
270
NEAREST_MIPMAP_LINEAR : 0x2702,
271
LINEAR_MIPMAP_LINEAR : 0x2703,
273
/* TextureParameterName */
274
TEXTURE_MAG_FILTER : 0x2800,
275
TEXTURE_MIN_FILTER : 0x2801,
276
TEXTURE_WRAP_S : 0x2802,
277
TEXTURE_WRAP_T : 0x2803,
283
TEXTURE_CUBE_MAP : 0x8513,
284
TEXTURE_BINDING_CUBE_MAP : 0x8514,
285
TEXTURE_CUBE_MAP_POSITIVE_X : 0x8515,
286
TEXTURE_CUBE_MAP_NEGATIVE_X : 0x8516,
287
TEXTURE_CUBE_MAP_POSITIVE_Y : 0x8517,
288
TEXTURE_CUBE_MAP_NEGATIVE_Y : 0x8518,
289
TEXTURE_CUBE_MAP_POSITIVE_Z : 0x8519,
290
TEXTURE_CUBE_MAP_NEGATIVE_Z : 0x851A,
291
MAX_CUBE_MAP_TEXTURE_SIZE : 0x851C,
326
ACTIVE_TEXTURE : 0x84E0,
328
/* TextureWrapMode */
330
CLAMP_TO_EDGE : 0x812F,
331
MIRRORED_REPEAT : 0x8370,
348
SAMPLER_CUBE : 0x8B60,
351
VERTEX_ATTRIB_ARRAY_ENABLED : 0x8622,
352
VERTEX_ATTRIB_ARRAY_SIZE : 0x8623,
353
VERTEX_ATTRIB_ARRAY_STRIDE : 0x8624,
354
VERTEX_ATTRIB_ARRAY_TYPE : 0x8625,
355
VERTEX_ATTRIB_ARRAY_NORMALIZED : 0x886A,
356
VERTEX_ATTRIB_ARRAY_POINTER : 0x8645,
357
VERTEX_ATTRIB_ARRAY_BUFFER_BINDING : 0x889F,
360
COMPILE_STATUS : 0x8B81,
362
/* Shader Precision-Specified Types */
364
MEDIUM_FLOAT : 0x8DF1,
370
/* Framebuffer Object. */
371
FRAMEBUFFER : 0x8D40,
372
RENDERBUFFER : 0x8D41,
377
DEPTH_COMPONENT16 : 0x81A5,
378
STENCIL_INDEX : 0x1901,
379
STENCIL_INDEX8 : 0x8D48,
380
DEPTH_STENCIL : 0x84F9,
382
RENDERBUFFER_WIDTH : 0x8D42,
383
RENDERBUFFER_HEIGHT : 0x8D43,
384
RENDERBUFFER_INTERNAL_FORMAT : 0x8D44,
385
RENDERBUFFER_RED_SIZE : 0x8D50,
386
RENDERBUFFER_GREEN_SIZE : 0x8D51,
387
RENDERBUFFER_BLUE_SIZE : 0x8D52,
388
RENDERBUFFER_ALPHA_SIZE : 0x8D53,
389
RENDERBUFFER_DEPTH_SIZE : 0x8D54,
390
RENDERBUFFER_STENCIL_SIZE : 0x8D55,
392
FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE : 0x8CD0,
393
FRAMEBUFFER_ATTACHMENT_OBJECT_NAME : 0x8CD1,
394
FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL : 0x8CD2,
395
FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE : 0x8CD3,
397
COLOR_ATTACHMENT0 : 0x8CE0,
398
DEPTH_ATTACHMENT : 0x8D00,
399
STENCIL_ATTACHMENT : 0x8D20,
400
DEPTH_STENCIL_ATTACHMENT : 0x821A,
404
FRAMEBUFFER_COMPLETE : 0x8CD5,
405
FRAMEBUFFER_INCOMPLETE_ATTACHMENT : 0x8CD6,
406
FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT : 0x8CD7,
407
FRAMEBUFFER_INCOMPLETE_DIMENSIONS : 0x8CD9,
408
FRAMEBUFFER_UNSUPPORTED : 0x8CDD,
410
FRAMEBUFFER_BINDING : 0x8CA6,
411
RENDERBUFFER_BINDING : 0x8CA7,
412
MAX_RENDERBUFFER_SIZE : 0x84E8,
414
INVALID_FRAMEBUFFER_OPERATION : 0x0506,
416
/* WebGL-specific enums */
417
UNPACK_FLIP_Y_WEBGL : 0x9240,
418
UNPACK_PREMULTIPLY_ALPHA_WEBGL : 0x9241,
419
CONTEXT_LOST_WEBGL : 0x9242,
420
UNPACK_COLORSPACE_CONVERSION_WEBGL : 0x9243,
421
BROWSER_DEFAULT_WEBGL : 0x9244,
425
getExtension: function() { return 1 },
426
createBuffer: function() {
433
deleteBuffer: function(){},
434
bindBuffer: function(){},
435
bufferData: function(){},
436
getParameter: function(pname) {
438
case /* GL_VENDOR */ 0x1F00: return 'FakeShellGLVendor';
439
case /* GL_RENDERER */ 0x1F01: return 'FakeShellGLRenderer';
440
case /* GL_VERSION */ 0x1F02: return '0.0.1';
441
case /* GL_MAX_TEXTURE_SIZE */ 0x0D33: return 16384;
442
case /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */ 0x851C: return 16384;
443
case /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */ 0x84FF: return 16;
444
case /* GL_MAX_TEXTURE_IMAGE_UNITS_NV */ 0x8872: return 16;
445
case /* GL_MAX_VERTEX_UNIFORM_VECTORS */ 0x8DFB: return 4096;
446
case /* GL_MAX_FRAGMENT_UNIFORM_VECTORS */ 0x8DFD: return 4096;
447
case /* GL_MAX_VARYING_VECTORS */ 0x8DFC: return 32;
448
case /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */ 0x8B4D: return 32;
449
default: console.log('getParameter ' + pname + '?'); return 0;
452
getSupportedExtensions: function() {
453
return ["OES_texture_float", "OES_standard_derivatives", "EXT_texture_filter_anisotropic", "MOZ_EXT_texture_filter_anisotropic", "MOZ_WEBGL_lose_context", "MOZ_WEBGL_compressed_texture_s3tc", "MOZ_WEBGL_depth_texture"];
455
createShader: function(type) {
463
getShaderParameter: function(shader, pname) {
465
case /* GL_SHADER_TYPE */ 0x8B4F: return this.items[shader].type;
466
case /* GL_COMPILE_STATUS */ 0x8B81: return true;
467
default: throw 'getShaderParameter ' + pname;
470
shaderSource: function(){},
471
compileShader: function(){},
472
createProgram: function() {
480
attachShader: function(program, shader) {
481
this.items[program].shaders.push(shader);
483
bindAttribLocation: function(){},
484
linkProgram: function(){},
485
getProgramParameter: function(program, pname) {
487
case /* LINK_STATUS */ 0x8B82: return true;
488
case /* ACTIVE_UNIFORMS */ 0x8B86: return 4;
489
default: throw 'getProgramParameter ' + pname;
492
deleteShader: function(){},
493
deleteProgram: function(){},
494
viewport: function(){},
495
clearColor: function(){},
496
clearDepth: function(){},
497
depthFunc: function(){},
498
enable: function(){},
499
disable: function(){},
500
frontFace: function(){},
501
cullFace: function(){},
502
activeTexture: function(){},
503
createTexture: function() {
510
deleteTexture: function(){},
512
bindTexture: function(target, texture) {
513
this.boundTextures[target] = texture;
515
texParameteri: function(){},
516
pixelStorei: function(){},
517
texImage2D: function(){},
518
compressedTexImage2D: function(){},
519
useProgram: function(){},
520
getUniformLocation: function() {
523
getActiveUniform: function(program, index) {
526
type: /* INT_VEC3 */ 0x8B54,
527
name: 'activeUniform' + index,
531
uniform4fv: function(){},
532
uniform1i: function(){},
533
getAttribLocation: function() { return 1 },
534
vertexAttribPointer: function(){},
535
enableVertexAttribArray: function(){},
536
disableVertexAttribArray: function(){},
537
drawElements: function(){},
538
drawArrays: function(){},
539
depthMask: function(){},
540
depthRange: function(){},
541
bufferSubData: function(){},
542
blendFunc: function(){},
543
createFramebuffer: function() {
546
which: 'framebuffer',
551
bindFramebuffer: function(){},
552
framebufferTexture2D: function(){},
553
checkFramebufferStatus: function() {
554
return /* FRAMEBUFFER_COMPLETE */ 0x8CD5;
556
createRenderbuffer: function() {
559
which: 'renderbuffer',
564
bindRenderbuffer: function(){},
565
renderbufferStorage: function(){},
566
framebufferRenderbuffer: function(){},
567
scissor: function(){},
568
colorMask: function(){},
569
lineWidth: function(){},
570
vertexAttrib4fv: function(){},
575
drawImage: function(){},
576
getImageData: function(x, y, w, h) {
580
data: new Uint8ClampedArray(w*h),
584
restore: function(){},
585
fillRect: function(){},
586
measureText: function() { return 10 },
587
fillText: function(){},
590
default: throw 'canvas.getContext: ' + which;
593
requestPointerLock: function() {
594
document.pointerLockElement = document.getElementById('canvas');
595
window.setTimeout(function() {
596
document.callEventListeners('pointerlockchange');
599
exitPointerLock: function(){},
602
addEventListener: function(){},
603
requestFullScreen: function() {
604
document.fullscreenElement = document.getElementById('canvas');
605
window.setTimeout(function() {
606
document.callEventListeners('fullscreenchange');
614
remove: function(){},