~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to src/headlessCanvas.js

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-09-20 22:44:35 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130920224435-apuwj4fsl3fqv1a6
Tags: 1.5.6~20130920~6010666-1
* New snapshot release
* Update the list of supported architectures to the same as libv8
  (Closes: #723129)
* emlibtool has been removed from upstream.
* Fix warning syntax-error-in-dep5-copyright
* Refresh of the patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function headlessCanvas() {
 
2
  return {
 
3
    headless: true,
 
4
    getContext: function(which) {
 
5
      switch(which) {
 
6
        case 'experimental-webgl': {
 
7
          return {
 
8
            /* ClearBufferMask */
 
9
            DEPTH_BUFFER_BIT               : 0x00000100,
 
10
            STENCIL_BUFFER_BIT             : 0x00000400,
 
11
            COLOR_BUFFER_BIT               : 0x00004000,
 
12
            
 
13
            /* BeginMode */
 
14
            POINTS                         : 0x0000,
 
15
            LINES                          : 0x0001,
 
16
            LINE_LOOP                      : 0x0002,
 
17
            LINE_STRIP                     : 0x0003,
 
18
            TRIANGLES                      : 0x0004,
 
19
            TRIANGLE_STRIP                 : 0x0005,
 
20
            TRIANGLE_FAN                   : 0x0006,
 
21
            
 
22
            /* AlphaFunction (not supported in ES20) */
 
23
            /*      NEVER */
 
24
            /*      LESS */
 
25
            /*      EQUAL */
 
26
            /*      LEQUAL */
 
27
            /*      GREATER */
 
28
            /*      NOTEQUAL */
 
29
            /*      GEQUAL */
 
30
            /*      ALWAYS */
 
31
            
 
32
            /* BlendingFactorDest */
 
33
            ZERO                           : 0,
 
34
            ONE                            : 1,
 
35
            SRC_COLOR                      : 0x0300,
 
36
            ONE_MINUS_SRC_COLOR            : 0x0301,
 
37
            SRC_ALPHA                      : 0x0302,
 
38
            ONE_MINUS_SRC_ALPHA            : 0x0303,
 
39
            DST_ALPHA                      : 0x0304,
 
40
            ONE_MINUS_DST_ALPHA            : 0x0305,
 
41
            
 
42
            /* BlendingFactorSrc */
 
43
            /*      ZERO */
 
44
            /*      ONE */
 
45
            DST_COLOR                      : 0x0306,
 
46
            ONE_MINUS_DST_COLOR            : 0x0307,
 
47
            SRC_ALPHA_SATURATE             : 0x0308,
 
48
            /*      SRC_ALPHA */
 
49
            /*      ONE_MINUS_SRC_ALPHA */
 
50
            /*      DST_ALPHA */
 
51
            /*      ONE_MINUS_DST_ALPHA */
 
52
            
 
53
            /* BlendEquationSeparate */
 
54
            FUNC_ADD                       : 0x8006,
 
55
            BLEND_EQUATION                 : 0x8009,
 
56
            BLEND_EQUATION_RGB             : 0x8009,   /* same as BLEND_EQUATION */
 
57
            BLEND_EQUATION_ALPHA           : 0x883D,
 
58
            
 
59
            /* BlendSubtract */
 
60
            FUNC_SUBTRACT                  : 0x800A,
 
61
            FUNC_REVERSE_SUBTRACT          : 0x800B,
 
62
            
 
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,
 
72
            BLEND_COLOR                    : 0x8005,
 
73
            
 
74
            /* Buffer Objects */
 
75
            ARRAY_BUFFER                   : 0x8892,
 
76
            ELEMENT_ARRAY_BUFFER           : 0x8893,
 
77
            ARRAY_BUFFER_BINDING           : 0x8894,
 
78
            ELEMENT_ARRAY_BUFFER_BINDING   : 0x8895,
 
79
            
 
80
            STREAM_DRAW                    : 0x88E0,
 
81
            STATIC_DRAW                    : 0x88E4,
 
82
            DYNAMIC_DRAW                   : 0x88E8,
 
83
            
 
84
            BUFFER_SIZE                    : 0x8764,
 
85
            BUFFER_USAGE                   : 0x8765,
 
86
            
 
87
            CURRENT_VERTEX_ATTRIB          : 0x8626,
 
88
            
 
89
            /* CullFaceMode */
 
90
            FRONT                          : 0x0404,
 
91
            BACK                           : 0x0405,
 
92
            FRONT_AND_BACK                 : 0x0408,
 
93
            
 
94
            /* DepthFunction */
 
95
            /*      NEVER */
 
96
            /*      LESS */
 
97
            /*      EQUAL */
 
98
            /*      LEQUAL */
 
99
            /*      GREATER */
 
100
            /*      NOTEQUAL */
 
101
            /*      GEQUAL */
 
102
            /*      ALWAYS */
 
103
            
 
104
            /* EnableCap */
 
105
            /* TEXTURE_2D */
 
106
            CULL_FACE                      : 0x0B44,
 
107
            BLEND                          : 0x0BE2,
 
108
            DITHER                         : 0x0BD0,
 
109
            STENCIL_TEST                   : 0x0B90,
 
110
            DEPTH_TEST                     : 0x0B71,
 
111
            SCISSOR_TEST                   : 0x0C11,
 
112
            POLYGON_OFFSET_FILL            : 0x8037,
 
113
            SAMPLE_ALPHA_TO_COVERAGE       : 0x809E,
 
114
            SAMPLE_COVERAGE                : 0x80A0,
 
115
            
 
116
            /* ErrorCode */
 
117
            NO_ERROR                       : 0,
 
118
            INVALID_ENUM                   : 0x0500,
 
119
            INVALID_VALUE                  : 0x0501,
 
120
            INVALID_OPERATION              : 0x0502,
 
121
            OUT_OF_MEMORY                  : 0x0505,
 
122
            
 
123
            /* FrontFaceDirection */
 
124
            CW                             : 0x0900,
 
125
            CCW                            : 0x0901,
 
126
            
 
127
            /* GetPName */
 
128
            LINE_WIDTH                     : 0x0B21,
 
129
            ALIASED_POINT_SIZE_RANGE       : 0x846D,
 
130
            ALIASED_LINE_WIDTH_RANGE       : 0x846E,
 
131
            CULL_FACE_MODE                 : 0x0B45,
 
132
            FRONT_FACE                     : 0x0B46,
 
133
            DEPTH_RANGE                    : 0x0B70,
 
134
            DEPTH_WRITEMASK                : 0x0B72,
 
135
            DEPTH_CLEAR_VALUE              : 0x0B73,
 
136
            DEPTH_FUNC                     : 0x0B74,
 
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,
 
152
            VIEWPORT                       : 0x0BA2,
 
153
            SCISSOR_BOX                    : 0x0C10,
 
154
            /*      SCISSOR_TEST */
 
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,
 
162
            RED_BITS                       : 0x0D52,
 
163
            GREEN_BITS                     : 0x0D53,
 
164
            BLUE_BITS                      : 0x0D54,
 
165
            ALPHA_BITS                     : 0x0D55,
 
166
            DEPTH_BITS                     : 0x0D56,
 
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,
 
173
            SAMPLES                        : 0x80A9,
 
174
            SAMPLE_COVERAGE_VALUE          : 0x80AA,
 
175
            SAMPLE_COVERAGE_INVERT         : 0x80AB,
 
176
            
 
177
            /* GetTextureParameter */
 
178
            /*      TEXTURE_MAG_FILTER */
 
179
            /*      TEXTURE_MIN_FILTER */
 
180
            /*      TEXTURE_WRAP_S */
 
181
            /*      TEXTURE_WRAP_T */
 
182
            
 
183
            COMPRESSED_TEXTURE_FORMATS     : 0x86A3,
 
184
            
 
185
            /* HintMode */
 
186
            DONT_CARE                      : 0x1100,
 
187
            FASTEST                        : 0x1101,
 
188
            NICEST                         : 0x1102,
 
189
            
 
190
            /* HintTarget */
 
191
            GENERATE_MIPMAP_HINT            : 0x8192,
 
192
            
 
193
            /* DataType */
 
194
            BYTE                           : 0x1400,
 
195
            UNSIGNED_BYTE                  : 0x1401,
 
196
            SHORT                          : 0x1402,
 
197
            UNSIGNED_SHORT                 : 0x1403,
 
198
            INT                            : 0x1404,
 
199
            UNSIGNED_INT                   : 0x1405,
 
200
            FLOAT                          : 0x1406,
 
201
            
 
202
            /* PixelFormat */
 
203
            DEPTH_COMPONENT                : 0x1902,
 
204
            ALPHA                          : 0x1906,
 
205
            RGB                            : 0x1907,
 
206
            RGBA                           : 0x1908,
 
207
            LUMINANCE                      : 0x1909,
 
208
            LUMINANCE_ALPHA                : 0x190A,
 
209
            
 
210
            /* PixelType */
 
211
            /*      UNSIGNED_BYTE */
 
212
            UNSIGNED_SHORT_4_4_4_4         : 0x8033,
 
213
            UNSIGNED_SHORT_5_5_5_1         : 0x8034,
 
214
            UNSIGNED_SHORT_5_6_5           : 0x8363,
 
215
            
 
216
            /* Shaders */
 
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,
 
235
            
 
236
            /* StencilFunction */
 
237
            NEVER                          : 0x0200,
 
238
            LESS                           : 0x0201,
 
239
            EQUAL                          : 0x0202,
 
240
            LEQUAL                         : 0x0203,
 
241
            GREATER                        : 0x0204,
 
242
            NOTEQUAL                       : 0x0205,
 
243
            GEQUAL                         : 0x0206,
 
244
            ALWAYS                         : 0x0207,
 
245
            
 
246
            /* StencilOp */
 
247
            /*      ZERO */
 
248
            KEEP                           : 0x1E00,
 
249
            REPLACE                        : 0x1E01,
 
250
            INCR                           : 0x1E02,
 
251
            DECR                           : 0x1E03,
 
252
            INVERT                         : 0x150A,
 
253
            INCR_WRAP                      : 0x8507,
 
254
            DECR_WRAP                      : 0x8508,
 
255
            
 
256
            /* StringName */
 
257
            VENDOR                         : 0x1F00,
 
258
            RENDERER                       : 0x1F01,
 
259
            VERSION                        : 0x1F02,
 
260
            
 
261
            /* TextureMagFilter */
 
262
            NEAREST                        : 0x2600,
 
263
            LINEAR                         : 0x2601,
 
264
            
 
265
            /* TextureMinFilter */
 
266
            /*      NEAREST */
 
267
            /*      LINEAR */
 
268
            NEAREST_MIPMAP_NEAREST         : 0x2700,
 
269
            LINEAR_MIPMAP_NEAREST          : 0x2701,
 
270
            NEAREST_MIPMAP_LINEAR          : 0x2702,
 
271
            LINEAR_MIPMAP_LINEAR           : 0x2703,
 
272
            
 
273
            /* TextureParameterName */
 
274
            TEXTURE_MAG_FILTER             : 0x2800,
 
275
            TEXTURE_MIN_FILTER             : 0x2801,
 
276
            TEXTURE_WRAP_S                 : 0x2802,
 
277
            TEXTURE_WRAP_T                 : 0x2803,
 
278
            
 
279
            /* TextureTarget */
 
280
            TEXTURE_2D                     : 0x0DE1,
 
281
            TEXTURE                        : 0x1702,
 
282
            
 
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,
 
292
            
 
293
            /* TextureUnit */
 
294
            TEXTURE0                       : 0x84C0,
 
295
            TEXTURE1                       : 0x84C1,
 
296
            TEXTURE2                       : 0x84C2,
 
297
            TEXTURE3                       : 0x84C3,
 
298
            TEXTURE4                       : 0x84C4,
 
299
            TEXTURE5                       : 0x84C5,
 
300
            TEXTURE6                       : 0x84C6,
 
301
            TEXTURE7                       : 0x84C7,
 
302
            TEXTURE8                       : 0x84C8,
 
303
            TEXTURE9                       : 0x84C9,
 
304
            TEXTURE10                      : 0x84CA,
 
305
            TEXTURE11                      : 0x84CB,
 
306
            TEXTURE12                      : 0x84CC,
 
307
            TEXTURE13                      : 0x84CD,
 
308
            TEXTURE14                      : 0x84CE,
 
309
            TEXTURE15                      : 0x84CF,
 
310
            TEXTURE16                      : 0x84D0,
 
311
            TEXTURE17                      : 0x84D1,
 
312
            TEXTURE18                      : 0x84D2,
 
313
            TEXTURE19                      : 0x84D3,
 
314
            TEXTURE20                      : 0x84D4,
 
315
            TEXTURE21                      : 0x84D5,
 
316
            TEXTURE22                      : 0x84D6,
 
317
            TEXTURE23                      : 0x84D7,
 
318
            TEXTURE24                      : 0x84D8,
 
319
            TEXTURE25                      : 0x84D9,
 
320
            TEXTURE26                      : 0x84DA,
 
321
            TEXTURE27                      : 0x84DB,
 
322
            TEXTURE28                      : 0x84DC,
 
323
            TEXTURE29                      : 0x84DD,
 
324
            TEXTURE30                      : 0x84DE,
 
325
            TEXTURE31                      : 0x84DF,
 
326
            ACTIVE_TEXTURE                 : 0x84E0,
 
327
            
 
328
            /* TextureWrapMode */
 
329
            REPEAT                         : 0x2901,
 
330
            CLAMP_TO_EDGE                  : 0x812F,
 
331
            MIRRORED_REPEAT                : 0x8370,
 
332
            
 
333
            /* Uniform Types */
 
334
            FLOAT_VEC2                     : 0x8B50,
 
335
            FLOAT_VEC3                     : 0x8B51,
 
336
            FLOAT_VEC4                     : 0x8B52,
 
337
            INT_VEC2                       : 0x8B53,
 
338
            INT_VEC3                       : 0x8B54,
 
339
            INT_VEC4                       : 0x8B55,
 
340
            BOOL                           : 0x8B56,
 
341
            BOOL_VEC2                      : 0x8B57,
 
342
            BOOL_VEC3                      : 0x8B58,
 
343
            BOOL_VEC4                      : 0x8B59,
 
344
            FLOAT_MAT2                     : 0x8B5A,
 
345
            FLOAT_MAT3                     : 0x8B5B,
 
346
            FLOAT_MAT4                     : 0x8B5C,
 
347
            SAMPLER_2D                     : 0x8B5E,
 
348
            SAMPLER_CUBE                   : 0x8B60,
 
349
            
 
350
            /* Vertex Arrays */
 
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,
 
358
            
 
359
            /* Shader Source */
 
360
            COMPILE_STATUS                 : 0x8B81,
 
361
            
 
362
            /* Shader Precision-Specified Types */
 
363
            LOW_FLOAT                      : 0x8DF0,
 
364
            MEDIUM_FLOAT                   : 0x8DF1,
 
365
            HIGH_FLOAT                     : 0x8DF2,
 
366
            LOW_INT                        : 0x8DF3,
 
367
            MEDIUM_INT                     : 0x8DF4,
 
368
            HIGH_INT                       : 0x8DF5,
 
369
            
 
370
            /* Framebuffer Object. */
 
371
            FRAMEBUFFER                    : 0x8D40,
 
372
            RENDERBUFFER                   : 0x8D41,
 
373
            
 
374
            RGBA4                          : 0x8056,
 
375
            RGB5_A1                        : 0x8057,
 
376
            RGB565                         : 0x8D62,
 
377
            DEPTH_COMPONENT16              : 0x81A5,
 
378
            STENCIL_INDEX                  : 0x1901,
 
379
            STENCIL_INDEX8                 : 0x8D48,
 
380
            DEPTH_STENCIL                  : 0x84F9,
 
381
            
 
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,
 
391
            
 
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,
 
396
            
 
397
            COLOR_ATTACHMENT0              : 0x8CE0,
 
398
            DEPTH_ATTACHMENT               : 0x8D00,
 
399
            STENCIL_ATTACHMENT             : 0x8D20,
 
400
            DEPTH_STENCIL_ATTACHMENT       : 0x821A,
 
401
            
 
402
            NONE                           : 0,
 
403
            
 
404
            FRAMEBUFFER_COMPLETE                      : 0x8CD5,
 
405
            FRAMEBUFFER_INCOMPLETE_ATTACHMENT         : 0x8CD6,
 
406
            FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT : 0x8CD7,
 
407
            FRAMEBUFFER_INCOMPLETE_DIMENSIONS         : 0x8CD9,
 
408
            FRAMEBUFFER_UNSUPPORTED                   : 0x8CDD,
 
409
            
 
410
            FRAMEBUFFER_BINDING            : 0x8CA6,
 
411
            RENDERBUFFER_BINDING           : 0x8CA7,
 
412
            MAX_RENDERBUFFER_SIZE          : 0x84E8,
 
413
            
 
414
            INVALID_FRAMEBUFFER_OPERATION  : 0x0506,
 
415
            
 
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,
 
422
 
 
423
            items: {},
 
424
            id: 0,
 
425
            getExtension: function() { return 1 },
 
426
            createBuffer: function() {
 
427
              var id = this.id++;
 
428
              this.items[id] = {
 
429
                which: 'buffer',
 
430
              };
 
431
              return id;
 
432
            },
 
433
            deleteBuffer: function(){},
 
434
            bindBuffer: function(){},
 
435
            bufferData: function(){},
 
436
            getParameter: function(pname) {
 
437
              switch(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;
 
450
              }
 
451
            },
 
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"];
 
454
            },
 
455
            createShader: function(type) {
 
456
              var id = this.id++;
 
457
              this.items[id] = {
 
458
                which: 'shader',
 
459
                type: type,
 
460
              };
 
461
              return id;
 
462
            },
 
463
            getShaderParameter: function(shader, pname) {
 
464
              switch(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;
 
468
              }
 
469
            },
 
470
            shaderSource: function(){},
 
471
            compileShader: function(){},
 
472
            createProgram: function() {
 
473
              var id = this.id++;
 
474
              this.items[id] = {
 
475
                which: 'program',
 
476
                shaders: [],
 
477
              };
 
478
              return id;
 
479
            },
 
480
            attachShader: function(program, shader) {
 
481
              this.items[program].shaders.push(shader);
 
482
            },
 
483
            bindAttribLocation: function(){},
 
484
            linkProgram: function(){},
 
485
            getProgramParameter: function(program, pname) {
 
486
              switch(pname) {
 
487
                case /* LINK_STATUS     */ 0x8B82: return true;
 
488
                case /* ACTIVE_UNIFORMS */ 0x8B86: return 4;
 
489
                default: throw 'getProgramParameter ' + pname;
 
490
              }
 
491
            },
 
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() {
 
504
              var id = this.id++;
 
505
              this.items[id] = {
 
506
                which: 'texture',
 
507
              };
 
508
              return id;
 
509
            },
 
510
            deleteTexture: function(){},
 
511
            boundTextures: {},
 
512
            bindTexture: function(target, texture) {
 
513
              this.boundTextures[target] = texture;
 
514
            },
 
515
            texParameteri: function(){},
 
516
            pixelStorei: function(){},
 
517
            texImage2D: function(){},
 
518
            compressedTexImage2D: function(){},
 
519
            useProgram: function(){},
 
520
            getUniformLocation: function() {
 
521
              return null;
 
522
            },
 
523
            getActiveUniform: function(program, index) {
 
524
              return {
 
525
                size: 1,
 
526
                type: /* INT_VEC3 */ 0x8B54,
 
527
                name: 'activeUniform' + index,
 
528
              };
 
529
            },
 
530
            clear: function(){},
 
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() {
 
544
              var id = this.id++;
 
545
              this.items[id] = {
 
546
                which: 'framebuffer',
 
547
                shaders: [],
 
548
              };
 
549
              return id;
 
550
            },
 
551
            bindFramebuffer: function(){},
 
552
            framebufferTexture2D: function(){},
 
553
            checkFramebufferStatus: function() {
 
554
              return /* FRAMEBUFFER_COMPLETE */ 0x8CD5;
 
555
            },
 
556
            createRenderbuffer: function() {
 
557
              var id = this.id++;
 
558
              this.items[id] = {
 
559
                which: 'renderbuffer',
 
560
                shaders: [],
 
561
              };
 
562
              return id;
 
563
            },
 
564
            bindRenderbuffer: function(){},
 
565
            renderbufferStorage: function(){},
 
566
            framebufferRenderbuffer: function(){},
 
567
            scissor: function(){},
 
568
            colorMask: function(){},
 
569
            lineWidth: function(){},
 
570
            vertexAttrib4fv: function(){},
 
571
          };
 
572
        }
 
573
        case '2d': {
 
574
          return {
 
575
            drawImage: function(){},
 
576
            getImageData: function(x, y, w, h) {
 
577
              return {
 
578
                width: w,
 
579
                height: h,
 
580
                data: new Uint8ClampedArray(w*h),
 
581
              };
 
582
            },
 
583
            save: function(){},
 
584
            restore: function(){},
 
585
            fillRect: function(){},
 
586
            measureText: function() { return 10 },
 
587
            fillText: function(){},
 
588
          };
 
589
        }
 
590
        default: throw 'canvas.getContext: ' + which;
 
591
      }
 
592
    },
 
593
    requestPointerLock: function() {
 
594
      document.pointerLockElement = document.getElementById('canvas');
 
595
      window.setTimeout(function() {
 
596
        document.callEventListeners('pointerlockchange');
 
597
      });
 
598
    },
 
599
    exitPointerLock: function(){},
 
600
    style: {},
 
601
    eventListeners: {},
 
602
    addEventListener: function(){},
 
603
    requestFullScreen: function() {
 
604
      document.fullscreenElement = document.getElementById('canvas');
 
605
      window.setTimeout(function() {
 
606
        document.callEventListeners('fullscreenchange');
 
607
      });
 
608
    },
 
609
    offsetTop: 0,
 
610
    offsetLeft: 0,
 
611
    // generics
 
612
    classList: {
 
613
      add: function(){},
 
614
      remove: function(){},
 
615
    },
 
616
  };
 
617
}
 
618