Home | History | Annotate | Download | only in canvas
      1 /*
      2  * Copyright (C) 2009 Apple Inc. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  * 1. Redistributions of source code must retain the above copyright
      8  *    notice, this list of conditions and the following disclaimer.
      9  * 2. Redistributions in binary form must reproduce the above copyright
     10  *    notice, this list of conditions and the following disclaimer in the
     11  *    documentation and/or other materials provided with the distribution.
     12  *
     13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
     14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
     17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24  */
     25 
     26 // http://www.khronos.org/registry/webgl/specs/latest/1.0/#WebGLRenderingContextBase
     27 
     28 typedef unsigned long  GLenum;
     29 typedef boolean        GLboolean;
     30 typedef unsigned long  GLbitfield;
     31 typedef byte           GLbyte; // 'byte' should be a signed 8 bit type.
     32 typedef short          GLshort;
     33 typedef long           GLint;
     34 typedef long           GLsizei;
     35 typedef long long      GLintptr;
     36 typedef long long      GLsizeiptr;
     37 typedef octet          GLubyte; // 'octet' should be an unsigned 8 bit type.
     38 typedef unsigned short GLushort;
     39 typedef unsigned long  GLuint;
     40 typedef unrestricted float GLfloat;
     41 typedef unrestricted float GLclampf;
     42 
     43 [
     44     // FIXME: [DoNotCheckConstants] and [TypeChecking=(Interface,Unrestricted)] should be applied
     45     // to members and not need to be put on implementing interface
     46     // DoNotCheckConstants, // need to put on implementing interface
     47     NoInterfaceObject, // Always used on target of 'implements'
     48     // TypeChecking=(Interface,Unrestricted), // need to put on implementing interface
     49     WillBeGarbageCollected,
     50 ] interface WebGLRenderingContextBase {
     51 
     52     readonly attribute HTMLCanvasElement canvas;
     53 
     54     /* ClearBufferMask */
     55     const GLenum DEPTH_BUFFER_BIT               = 0x00000100;
     56     const GLenum STENCIL_BUFFER_BIT             = 0x00000400;
     57     const GLenum COLOR_BUFFER_BIT               = 0x00004000;
     58 
     59     /* BeginMode */
     60     const GLenum POINTS                         = 0x0000;
     61     const GLenum LINES                          = 0x0001;
     62     const GLenum LINE_LOOP                      = 0x0002;
     63     const GLenum LINE_STRIP                     = 0x0003;
     64     const GLenum TRIANGLES                      = 0x0004;
     65     const GLenum TRIANGLE_STRIP                 = 0x0005;
     66     const GLenum TRIANGLE_FAN                   = 0x0006;
     67 
     68     /* AlphaFunction (not supported in ES20) */
     69     /*      NEVER */
     70     /*      LESS */
     71     /*      EQUAL */
     72     /*      LEQUAL */
     73     /*      GREATER */
     74     /*      NOTEQUAL */
     75     /*      GEQUAL */
     76     /*      ALWAYS */
     77 
     78     /* BlendingFactorDest */
     79     const GLenum ZERO                           = 0;
     80     const GLenum ONE                            = 1;
     81     const GLenum SRC_COLOR                      = 0x0300;
     82     const GLenum ONE_MINUS_SRC_COLOR            = 0x0301;
     83     const GLenum SRC_ALPHA                      = 0x0302;
     84     const GLenum ONE_MINUS_SRC_ALPHA            = 0x0303;
     85     const GLenum DST_ALPHA                      = 0x0304;
     86     const GLenum ONE_MINUS_DST_ALPHA            = 0x0305;
     87 
     88     /* BlendingFactorSrc */
     89     /*      ZERO */
     90     /*      ONE */
     91     const GLenum DST_COLOR                      = 0x0306;
     92     const GLenum ONE_MINUS_DST_COLOR            = 0x0307;
     93     const GLenum SRC_ALPHA_SATURATE             = 0x0308;
     94     /*      SRC_ALPHA */
     95     /*      ONE_MINUS_SRC_ALPHA */
     96     /*      DST_ALPHA */
     97     /*      ONE_MINUS_DST_ALPHA */
     98 
     99     /* BlendEquationSeparate */
    100     const GLenum FUNC_ADD                       = 0x8006;
    101     const GLenum BLEND_EQUATION                 = 0x8009;
    102     const GLenum BLEND_EQUATION_RGB             = 0x8009;   /* same as BLEND_EQUATION */
    103     const GLenum BLEND_EQUATION_ALPHA           = 0x883D;
    104 
    105     /* BlendSubtract */
    106     const GLenum FUNC_SUBTRACT                  = 0x800A;
    107     const GLenum FUNC_REVERSE_SUBTRACT          = 0x800B;
    108 
    109     /* Separate Blend Functions */
    110     const GLenum BLEND_DST_RGB                  = 0x80C8;
    111     const GLenum BLEND_SRC_RGB                  = 0x80C9;
    112     const GLenum BLEND_DST_ALPHA                = 0x80CA;
    113     const GLenum BLEND_SRC_ALPHA                = 0x80CB;
    114     const GLenum CONSTANT_COLOR                 = 0x8001;
    115     const GLenum ONE_MINUS_CONSTANT_COLOR       = 0x8002;
    116     const GLenum CONSTANT_ALPHA                 = 0x8003;
    117     const GLenum ONE_MINUS_CONSTANT_ALPHA       = 0x8004;
    118     const GLenum BLEND_COLOR                    = 0x8005;
    119 
    120     /* Buffer Objects */
    121     const GLenum ARRAY_BUFFER                   = 0x8892;
    122     const GLenum ELEMENT_ARRAY_BUFFER           = 0x8893;
    123     const GLenum ARRAY_BUFFER_BINDING           = 0x8894;
    124     const GLenum ELEMENT_ARRAY_BUFFER_BINDING   = 0x8895;
    125 
    126     const GLenum STREAM_DRAW                    = 0x88E0;
    127     const GLenum STATIC_DRAW                    = 0x88E4;
    128     const GLenum DYNAMIC_DRAW                   = 0x88E8;
    129 
    130     const GLenum BUFFER_SIZE                    = 0x8764;
    131     const GLenum BUFFER_USAGE                   = 0x8765;
    132 
    133     const GLenum CURRENT_VERTEX_ATTRIB          = 0x8626;
    134 
    135     /* CullFaceMode */
    136     const GLenum FRONT                          = 0x0404;
    137     const GLenum BACK                           = 0x0405;
    138     const GLenum FRONT_AND_BACK                 = 0x0408;
    139 
    140     /* DepthFunction */
    141     /*      NEVER */
    142     /*      LESS */
    143     /*      EQUAL */
    144     /*      LEQUAL */
    145     /*      GREATER */
    146     /*      NOTEQUAL */
    147     /*      GEQUAL */
    148     /*      ALWAYS */
    149 
    150     /* EnableCap */
    151     const GLenum TEXTURE_2D                     = 0x0DE1;
    152     const GLenum CULL_FACE                      = 0x0B44;
    153     const GLenum BLEND                          = 0x0BE2;
    154     const GLenum DITHER                         = 0x0BD0;
    155     const GLenum STENCIL_TEST                   = 0x0B90;
    156     const GLenum DEPTH_TEST                     = 0x0B71;
    157     const GLenum SCISSOR_TEST                   = 0x0C11;
    158     const GLenum POLYGON_OFFSET_FILL            = 0x8037;
    159     const GLenum SAMPLE_ALPHA_TO_COVERAGE       = 0x809E;
    160     const GLenum SAMPLE_COVERAGE                = 0x80A0;
    161 
    162     /* ErrorCode */
    163     const GLenum NO_ERROR                       = 0;
    164     const GLenum INVALID_ENUM                   = 0x0500;
    165     const GLenum INVALID_VALUE                  = 0x0501;
    166     const GLenum INVALID_OPERATION              = 0x0502;
    167     const GLenum OUT_OF_MEMORY                  = 0x0505;
    168 
    169     /* FrontFaceDirection */
    170     const GLenum CW                             = 0x0900;
    171     const GLenum CCW                            = 0x0901;
    172 
    173     /* GetPName */
    174     const GLenum LINE_WIDTH                     = 0x0B21;
    175     const GLenum ALIASED_POINT_SIZE_RANGE       = 0x846D;
    176     const GLenum ALIASED_LINE_WIDTH_RANGE       = 0x846E;
    177     const GLenum CULL_FACE_MODE                 = 0x0B45;
    178     const GLenum FRONT_FACE                     = 0x0B46;
    179     const GLenum DEPTH_RANGE                    = 0x0B70;
    180     const GLenum DEPTH_WRITEMASK                = 0x0B72;
    181     const GLenum DEPTH_CLEAR_VALUE              = 0x0B73;
    182     const GLenum DEPTH_FUNC                     = 0x0B74;
    183     const GLenum STENCIL_CLEAR_VALUE            = 0x0B91;
    184     const GLenum STENCIL_FUNC                   = 0x0B92;
    185     const GLenum STENCIL_FAIL                   = 0x0B94;
    186     const GLenum STENCIL_PASS_DEPTH_FAIL        = 0x0B95;
    187     const GLenum STENCIL_PASS_DEPTH_PASS        = 0x0B96;
    188     const GLenum STENCIL_REF                    = 0x0B97;
    189     const GLenum STENCIL_VALUE_MASK             = 0x0B93;
    190     const GLenum STENCIL_WRITEMASK              = 0x0B98;
    191     const GLenum STENCIL_BACK_FUNC              = 0x8800;
    192     const GLenum STENCIL_BACK_FAIL              = 0x8801;
    193     const GLenum STENCIL_BACK_PASS_DEPTH_FAIL   = 0x8802;
    194     const GLenum STENCIL_BACK_PASS_DEPTH_PASS   = 0x8803;
    195     const GLenum STENCIL_BACK_REF               = 0x8CA3;
    196     const GLenum STENCIL_BACK_VALUE_MASK        = 0x8CA4;
    197     const GLenum STENCIL_BACK_WRITEMASK         = 0x8CA5;
    198     const GLenum VIEWPORT                       = 0x0BA2;
    199     const GLenum SCISSOR_BOX                    = 0x0C10;
    200     /*      SCISSOR_TEST */
    201     const GLenum COLOR_CLEAR_VALUE              = 0x0C22;
    202     const GLenum COLOR_WRITEMASK                = 0x0C23;
    203     const GLenum UNPACK_ALIGNMENT               = 0x0CF5;
    204     const GLenum PACK_ALIGNMENT                 = 0x0D05;
    205     const GLenum MAX_TEXTURE_SIZE               = 0x0D33;
    206     const GLenum MAX_VIEWPORT_DIMS              = 0x0D3A;
    207     const GLenum SUBPIXEL_BITS                  = 0x0D50;
    208     const GLenum RED_BITS                       = 0x0D52;
    209     const GLenum GREEN_BITS                     = 0x0D53;
    210     const GLenum BLUE_BITS                      = 0x0D54;
    211     const GLenum ALPHA_BITS                     = 0x0D55;
    212     const GLenum DEPTH_BITS                     = 0x0D56;
    213     const GLenum STENCIL_BITS                   = 0x0D57;
    214     const GLenum POLYGON_OFFSET_UNITS           = 0x2A00;
    215     /*      POLYGON_OFFSET_FILL */
    216     const GLenum POLYGON_OFFSET_FACTOR          = 0x8038;
    217     const GLenum TEXTURE_BINDING_2D             = 0x8069;
    218     const GLenum SAMPLE_BUFFERS                 = 0x80A8;
    219     const GLenum SAMPLES                        = 0x80A9;
    220     const GLenum SAMPLE_COVERAGE_VALUE          = 0x80AA;
    221     const GLenum SAMPLE_COVERAGE_INVERT         = 0x80AB;
    222 
    223     /* GetTextureParameter */
    224     /*      TEXTURE_MAG_FILTER */
    225     /*      TEXTURE_MIN_FILTER */
    226     /*      TEXTURE_WRAP_S */
    227     /*      TEXTURE_WRAP_T */
    228 
    229     const GLenum COMPRESSED_TEXTURE_FORMATS     = 0x86A3;
    230 
    231     /* HintMode */
    232     const GLenum DONT_CARE                      = 0x1100;
    233     const GLenum FASTEST                        = 0x1101;
    234     const GLenum NICEST                         = 0x1102;
    235 
    236     /* HintTarget */
    237     const GLenum GENERATE_MIPMAP_HINT            = 0x8192;
    238 
    239     /* DataType */
    240     const GLenum BYTE                           = 0x1400;
    241     const GLenum UNSIGNED_BYTE                  = 0x1401;
    242     const GLenum SHORT                          = 0x1402;
    243     const GLenum UNSIGNED_SHORT                 = 0x1403;
    244     const GLenum INT                            = 0x1404;
    245     const GLenum UNSIGNED_INT                   = 0x1405;
    246     const GLenum FLOAT                          = 0x1406;
    247 
    248     /* PixelFormat */
    249     const GLenum DEPTH_COMPONENT                = 0x1902;
    250     const GLenum ALPHA                          = 0x1906;
    251     const GLenum RGB                            = 0x1907;
    252     const GLenum RGBA                           = 0x1908;
    253     const GLenum LUMINANCE                      = 0x1909;
    254     const GLenum LUMINANCE_ALPHA                = 0x190A;
    255 
    256     /* PixelType */
    257     /*      UNSIGNED_BYTE */
    258     const GLenum UNSIGNED_SHORT_4_4_4_4         = 0x8033;
    259     const GLenum UNSIGNED_SHORT_5_5_5_1         = 0x8034;
    260     const GLenum UNSIGNED_SHORT_5_6_5           = 0x8363;
    261 
    262     /* Shaders */
    263     const GLenum FRAGMENT_SHADER                  = 0x8B30;
    264     const GLenum VERTEX_SHADER                    = 0x8B31;
    265     const GLenum MAX_VERTEX_ATTRIBS               = 0x8869;
    266     const GLenum MAX_VERTEX_UNIFORM_VECTORS       = 0x8DFB;
    267     const GLenum MAX_VARYING_VECTORS              = 0x8DFC;
    268     const GLenum MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D;
    269     const GLenum MAX_VERTEX_TEXTURE_IMAGE_UNITS   = 0x8B4C;
    270     const GLenum MAX_TEXTURE_IMAGE_UNITS          = 0x8872;
    271     const GLenum MAX_FRAGMENT_UNIFORM_VECTORS     = 0x8DFD;
    272     const GLenum SHADER_TYPE                      = 0x8B4F;
    273     const GLenum DELETE_STATUS                    = 0x8B80;
    274     const GLenum LINK_STATUS                      = 0x8B82;
    275     const GLenum VALIDATE_STATUS                  = 0x8B83;
    276     const GLenum ATTACHED_SHADERS                 = 0x8B85;
    277     const GLenum ACTIVE_UNIFORMS                  = 0x8B86;
    278     const GLenum ACTIVE_ATTRIBUTES                = 0x8B89;
    279     const GLenum SHADING_LANGUAGE_VERSION         = 0x8B8C;
    280     const GLenum CURRENT_PROGRAM                  = 0x8B8D;
    281 
    282     /* StencilFunction */
    283     const GLenum NEVER                          = 0x0200;
    284     const GLenum LESS                           = 0x0201;
    285     const GLenum EQUAL                          = 0x0202;
    286     const GLenum LEQUAL                         = 0x0203;
    287     const GLenum GREATER                        = 0x0204;
    288     const GLenum NOTEQUAL                       = 0x0205;
    289     const GLenum GEQUAL                         = 0x0206;
    290     const GLenum ALWAYS                         = 0x0207;
    291 
    292     /* StencilOp */
    293     /*      ZERO */
    294     const GLenum KEEP                           = 0x1E00;
    295     const GLenum REPLACE                        = 0x1E01;
    296     const GLenum INCR                           = 0x1E02;
    297     const GLenum DECR                           = 0x1E03;
    298     const GLenum INVERT                         = 0x150A;
    299     const GLenum INCR_WRAP                      = 0x8507;
    300     const GLenum DECR_WRAP                      = 0x8508;
    301 
    302     /* StringName */
    303     const GLenum VENDOR                         = 0x1F00;
    304     const GLenum RENDERER                       = 0x1F01;
    305     const GLenum VERSION                        = 0x1F02;
    306 
    307     /* TextureMagFilter */
    308     const GLenum NEAREST                        = 0x2600;
    309     const GLenum LINEAR                         = 0x2601;
    310 
    311     /* TextureMinFilter */
    312     /*      NEAREST */
    313     /*      LINEAR */
    314     const GLenum NEAREST_MIPMAP_NEAREST         = 0x2700;
    315     const GLenum LINEAR_MIPMAP_NEAREST          = 0x2701;
    316     const GLenum NEAREST_MIPMAP_LINEAR          = 0x2702;
    317     const GLenum LINEAR_MIPMAP_LINEAR           = 0x2703;
    318 
    319     /* TextureParameterName */
    320     const GLenum TEXTURE_MAG_FILTER             = 0x2800;
    321     const GLenum TEXTURE_MIN_FILTER             = 0x2801;
    322     const GLenum TEXTURE_WRAP_S                 = 0x2802;
    323     const GLenum TEXTURE_WRAP_T                 = 0x2803;
    324 
    325     /* TextureTarget */
    326     /*      TEXTURE_2D */
    327     const GLenum TEXTURE                        = 0x1702;
    328 
    329     const GLenum TEXTURE_CUBE_MAP               = 0x8513;
    330     const GLenum TEXTURE_BINDING_CUBE_MAP       = 0x8514;
    331     const GLenum TEXTURE_CUBE_MAP_POSITIVE_X    = 0x8515;
    332     const GLenum TEXTURE_CUBE_MAP_NEGATIVE_X    = 0x8516;
    333     const GLenum TEXTURE_CUBE_MAP_POSITIVE_Y    = 0x8517;
    334     const GLenum TEXTURE_CUBE_MAP_NEGATIVE_Y    = 0x8518;
    335     const GLenum TEXTURE_CUBE_MAP_POSITIVE_Z    = 0x8519;
    336     const GLenum TEXTURE_CUBE_MAP_NEGATIVE_Z    = 0x851A;
    337     const GLenum MAX_CUBE_MAP_TEXTURE_SIZE      = 0x851C;
    338 
    339     /* TextureUnit */
    340     const GLenum TEXTURE0                       = 0x84C0;
    341     const GLenum TEXTURE1                       = 0x84C1;
    342     const GLenum TEXTURE2                       = 0x84C2;
    343     const GLenum TEXTURE3                       = 0x84C3;
    344     const GLenum TEXTURE4                       = 0x84C4;
    345     const GLenum TEXTURE5                       = 0x84C5;
    346     const GLenum TEXTURE6                       = 0x84C6;
    347     const GLenum TEXTURE7                       = 0x84C7;
    348     const GLenum TEXTURE8                       = 0x84C8;
    349     const GLenum TEXTURE9                       = 0x84C9;
    350     const GLenum TEXTURE10                      = 0x84CA;
    351     const GLenum TEXTURE11                      = 0x84CB;
    352     const GLenum TEXTURE12                      = 0x84CC;
    353     const GLenum TEXTURE13                      = 0x84CD;
    354     const GLenum TEXTURE14                      = 0x84CE;
    355     const GLenum TEXTURE15                      = 0x84CF;
    356     const GLenum TEXTURE16                      = 0x84D0;
    357     const GLenum TEXTURE17                      = 0x84D1;
    358     const GLenum TEXTURE18                      = 0x84D2;
    359     const GLenum TEXTURE19                      = 0x84D3;
    360     const GLenum TEXTURE20                      = 0x84D4;
    361     const GLenum TEXTURE21                      = 0x84D5;
    362     const GLenum TEXTURE22                      = 0x84D6;
    363     const GLenum TEXTURE23                      = 0x84D7;
    364     const GLenum TEXTURE24                      = 0x84D8;
    365     const GLenum TEXTURE25                      = 0x84D9;
    366     const GLenum TEXTURE26                      = 0x84DA;
    367     const GLenum TEXTURE27                      = 0x84DB;
    368     const GLenum TEXTURE28                      = 0x84DC;
    369     const GLenum TEXTURE29                      = 0x84DD;
    370     const GLenum TEXTURE30                      = 0x84DE;
    371     const GLenum TEXTURE31                      = 0x84DF;
    372     const GLenum ACTIVE_TEXTURE                 = 0x84E0;
    373 
    374     /* TextureWrapMode */
    375     const GLenum REPEAT                         = 0x2901;
    376     const GLenum CLAMP_TO_EDGE                  = 0x812F;
    377     const GLenum MIRRORED_REPEAT                = 0x8370;
    378 
    379     /* Uniform Types */
    380     const GLenum FLOAT_VEC2                     = 0x8B50;
    381     const GLenum FLOAT_VEC3                     = 0x8B51;
    382     const GLenum FLOAT_VEC4                     = 0x8B52;
    383     const GLenum INT_VEC2                       = 0x8B53;
    384     const GLenum INT_VEC3                       = 0x8B54;
    385     const GLenum INT_VEC4                       = 0x8B55;
    386     const GLenum BOOL                           = 0x8B56;
    387     const GLenum BOOL_VEC2                      = 0x8B57;
    388     const GLenum BOOL_VEC3                      = 0x8B58;
    389     const GLenum BOOL_VEC4                      = 0x8B59;
    390     const GLenum FLOAT_MAT2                     = 0x8B5A;
    391     const GLenum FLOAT_MAT3                     = 0x8B5B;
    392     const GLenum FLOAT_MAT4                     = 0x8B5C;
    393     const GLenum SAMPLER_2D                     = 0x8B5E;
    394     const GLenum SAMPLER_CUBE                   = 0x8B60;
    395 
    396     /* Vertex Arrays */
    397     const GLenum VERTEX_ATTRIB_ARRAY_ENABLED        = 0x8622;
    398     const GLenum VERTEX_ATTRIB_ARRAY_SIZE           = 0x8623;
    399     const GLenum VERTEX_ATTRIB_ARRAY_STRIDE         = 0x8624;
    400     const GLenum VERTEX_ATTRIB_ARRAY_TYPE           = 0x8625;
    401     const GLenum VERTEX_ATTRIB_ARRAY_NORMALIZED     = 0x886A;
    402     const GLenum VERTEX_ATTRIB_ARRAY_POINTER        = 0x8645;
    403     const GLenum VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F;
    404 
    405     /* Read Format */
    406     const GLenum IMPLEMENTATION_COLOR_READ_TYPE   = 0x8B9A;
    407     const GLenum IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B;
    408 
    409     /* Shader Source */
    410     const GLenum COMPILE_STATUS                 = 0x8B81;
    411 
    412     /* Shader Precision-Specified Types */
    413     const GLenum LOW_FLOAT                      = 0x8DF0;
    414     const GLenum MEDIUM_FLOAT                   = 0x8DF1;
    415     const GLenum HIGH_FLOAT                     = 0x8DF2;
    416     const GLenum LOW_INT                        = 0x8DF3;
    417     const GLenum MEDIUM_INT                     = 0x8DF4;
    418     const GLenum HIGH_INT                       = 0x8DF5;
    419 
    420     /* Framebuffer Object. */
    421     const GLenum FRAMEBUFFER                    = 0x8D40;
    422     const GLenum RENDERBUFFER                   = 0x8D41;
    423 
    424     const GLenum RGBA4                          = 0x8056;
    425     const GLenum RGB5_A1                        = 0x8057;
    426     const GLenum RGB565                         = 0x8D62;
    427     const GLenum DEPTH_COMPONENT16              = 0x81A5;
    428     const GLenum STENCIL_INDEX                  = 0x1901;
    429     const GLenum STENCIL_INDEX8                 = 0x8D48;
    430     const GLenum DEPTH_STENCIL                  = 0x84F9;
    431 
    432     const GLenum RENDERBUFFER_WIDTH             = 0x8D42;
    433     const GLenum RENDERBUFFER_HEIGHT            = 0x8D43;
    434     const GLenum RENDERBUFFER_INTERNAL_FORMAT   = 0x8D44;
    435     const GLenum RENDERBUFFER_RED_SIZE          = 0x8D50;
    436     const GLenum RENDERBUFFER_GREEN_SIZE        = 0x8D51;
    437     const GLenum RENDERBUFFER_BLUE_SIZE         = 0x8D52;
    438     const GLenum RENDERBUFFER_ALPHA_SIZE        = 0x8D53;
    439     const GLenum RENDERBUFFER_DEPTH_SIZE        = 0x8D54;
    440     const GLenum RENDERBUFFER_STENCIL_SIZE      = 0x8D55;
    441 
    442     const GLenum FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE           = 0x8CD0;
    443     const GLenum FRAMEBUFFER_ATTACHMENT_OBJECT_NAME           = 0x8CD1;
    444     const GLenum FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL         = 0x8CD2;
    445     const GLenum FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3;
    446 
    447     const GLenum COLOR_ATTACHMENT0              = 0x8CE0;
    448     const GLenum DEPTH_ATTACHMENT               = 0x8D00;
    449     const GLenum STENCIL_ATTACHMENT             = 0x8D20;
    450     const GLenum DEPTH_STENCIL_ATTACHMENT       = 0x821A;
    451 
    452     const GLenum NONE                           = 0;
    453 
    454     const GLenum FRAMEBUFFER_COMPLETE                      = 0x8CD5;
    455     const GLenum FRAMEBUFFER_INCOMPLETE_ATTACHMENT         = 0x8CD6;
    456     const GLenum FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7;
    457     const GLenum FRAMEBUFFER_INCOMPLETE_DIMENSIONS         = 0x8CD9;
    458     const GLenum FRAMEBUFFER_UNSUPPORTED                   = 0x8CDD;
    459 
    460     const GLenum FRAMEBUFFER_BINDING            = 0x8CA6;
    461     const GLenum RENDERBUFFER_BINDING           = 0x8CA7;
    462     const GLenum MAX_RENDERBUFFER_SIZE          = 0x84E8;
    463 
    464     const GLenum INVALID_FRAMEBUFFER_OPERATION  = 0x0506;
    465 
    466     /* WebGL-specific enums */
    467     const GLenum UNPACK_FLIP_Y_WEBGL                = 0x9240;
    468     const GLenum UNPACK_PREMULTIPLY_ALPHA_WEBGL     = 0x9241;
    469     const GLenum CONTEXT_LOST_WEBGL                 = 0x9242;
    470     const GLenum UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243;
    471     const GLenum BROWSER_DEFAULT_WEBGL              = 0x9244;
    472 
    473     readonly attribute GLsizei drawingBufferWidth;
    474     readonly attribute GLsizei drawingBufferHeight;
    475 
    476     void activeTexture(GLenum texture);
    477     void attachShader(WebGLProgram? program, WebGLShader? shader);
    478     void bindAttribLocation(WebGLProgram? program, GLuint index, DOMString name);
    479     void bindBuffer(GLenum target, WebGLBuffer? buffer);
    480     void bindFramebuffer(GLenum target, WebGLFramebuffer? framebuffer);
    481     void bindRenderbuffer(GLenum target, WebGLRenderbuffer? renderbuffer);
    482     void bindTexture(GLenum target, WebGLTexture? texture);
    483     void blendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
    484     void blendEquation(GLenum mode);
    485     void blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
    486     void blendFunc(GLenum sfactor, GLenum dfactor);
    487     void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
    488     // FIXME: should be union type
    489     // https://www.khronos.org/bugzilla/show_bug.cgi?id=1172
    490     void bufferData(GLenum target, GLsizeiptr size, GLenum usage);
    491     void bufferData(GLenum target, ArrayBufferView data, GLenum usage);
    492     void bufferData(GLenum target, ArrayBuffer? data, GLenum usage);
    493     void bufferSubData(GLenum target, GLintptr offset, ArrayBufferView data);
    494     void bufferSubData(GLenum target, GLintptr offset, ArrayBuffer? data);
    495 
    496     GLenum checkFramebufferStatus(GLenum target);
    497     void clear(GLbitfield mask);
    498     void clearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
    499     void clearDepth(GLclampf depth);
    500     void clearStencil(GLint s);
    501     void colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
    502     void compileShader(WebGLShader? shader);
    503 
    504     void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat,
    505                               GLsizei width, GLsizei height, GLint border, ArrayBufferView? data);
    506     void compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
    507                                  GLsizei width, GLsizei height, GLenum format, ArrayBufferView? data);
    508 
    509     void copyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
    510     void copyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
    511 
    512     WebGLBuffer createBuffer();
    513     WebGLFramebuffer createFramebuffer();
    514     WebGLProgram createProgram();
    515     WebGLRenderbuffer createRenderbuffer();
    516     WebGLShader createShader(GLenum type);
    517     WebGLTexture createTexture();
    518 
    519     void cullFace(GLenum mode);
    520 
    521     void deleteBuffer(WebGLBuffer? buffer);
    522     void deleteFramebuffer(WebGLFramebuffer? framebuffer);
    523     void deleteProgram(WebGLProgram? program);
    524     void deleteRenderbuffer(WebGLRenderbuffer? renderbuffer);
    525     void deleteShader(WebGLShader? shader);
    526     void deleteTexture(WebGLTexture? texture);
    527 
    528     void depthFunc(GLenum func);
    529     void depthMask(GLboolean flag);
    530     void depthRange(GLclampf zNear, GLclampf zFar);
    531     void detachShader(WebGLProgram? program, WebGLShader? shader);
    532     void disable(GLenum cap);
    533     void disableVertexAttribArray(GLuint index);
    534     void drawArrays(GLenum mode, GLint first, GLsizei count);
    535     void drawElements(GLenum mode, GLsizei count, GLenum type, GLintptr offset);
    536 
    537     void enable(GLenum cap);
    538     void enableVertexAttribArray(GLuint index);
    539     void finish();
    540     void flush();
    541     void framebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, WebGLRenderbuffer? renderbuffer);
    542     void framebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, WebGLTexture? texture, GLint level);
    543     void frontFace(GLenum mode);
    544     void generateMipmap(GLenum target);
    545 
    546     WebGLActiveInfo getActiveAttrib(WebGLProgram? program, GLuint index);
    547     WebGLActiveInfo getActiveUniform(WebGLProgram? program, GLuint index);
    548 
    549     sequence<WebGLShader>? getAttachedShaders(WebGLProgram? program);
    550 
    551     GLint getAttribLocation(WebGLProgram? program, DOMString name);
    552 
    553     [Custom] any getBufferParameter(GLenum target, GLenum pname);
    554 
    555     WebGLContextAttributes getContextAttributes();
    556 
    557     GLenum getError();
    558 
    559     // object getExtension(DOMString name);
    560     [Custom] any getExtension(DOMString name);
    561 
    562     [Custom] any getFramebufferAttachmentParameter(GLenum target, GLenum attachment, GLenum pname);
    563     [Custom] any getParameter(GLenum pname);
    564     [Custom] any getProgramParameter(WebGLProgram? program, GLenum pname);
    565     DOMString? getProgramInfoLog(WebGLProgram? program);
    566     [Custom] any getRenderbufferParameter(GLenum target, GLenum pname);
    567     [Custom] any getShaderParameter(WebGLShader? shader, GLenum pname);
    568 
    569     DOMString?   getShaderInfoLog(WebGLShader? shader);
    570 
    571     WebGLShaderPrecisionFormat getShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype);
    572 
    573     DOMString?   getShaderSource(WebGLShader? shader);
    574 
    575     sequence<DOMString>? getSupportedExtensions();
    576 
    577     [Custom] any getTexParameter(GLenum target, GLenum pname);
    578 
    579     [Custom] any getUniform(WebGLProgram? program, WebGLUniformLocation? location);
    580 
    581     WebGLUniformLocation getUniformLocation(WebGLProgram? program, DOMString name);
    582 
    583     [Custom] any getVertexAttrib(GLuint index, GLenum pname);
    584 
    585     GLsizeiptr getVertexAttribOffset(GLuint index, GLenum pname);
    586 
    587     void hint(GLenum target, GLenum mode);
    588     GLboolean isBuffer(WebGLBuffer? buffer);
    589     GLboolean isContextLost();
    590     GLboolean isEnabled(GLenum cap);
    591     GLboolean isFramebuffer(WebGLFramebuffer? framebuffer);
    592     GLboolean isProgram(WebGLProgram? program);
    593     GLboolean isRenderbuffer(WebGLRenderbuffer? renderbuffer);
    594     GLboolean isShader(WebGLShader? shader);
    595     GLboolean isTexture(WebGLTexture? texture);
    596     void lineWidth(GLfloat width);
    597     void linkProgram(WebGLProgram? program);
    598     void pixelStorei(GLenum pname, GLint param);
    599     void polygonOffset(GLfloat factor, GLfloat units);
    600 
    601     void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, ArrayBufferView? pixels);
    602 
    603     void renderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
    604     void sampleCoverage(GLclampf value, GLboolean invert);
    605     void scissor(GLint x, GLint y, GLsizei width, GLsizei height);
    606     void shaderSource(WebGLShader? shader, DOMString string);
    607     void stencilFunc(GLenum func, GLint ref, GLuint mask);
    608     void stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
    609     void stencilMask(GLuint mask);
    610     void stencilMaskSeparate(GLenum face, GLuint mask);
    611     void stencilOp(GLenum fail, GLenum zfail, GLenum zpass);
    612     void stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
    613 
    614     void texParameterf(GLenum target, GLenum pname, GLfloat param);
    615     void texParameteri(GLenum target, GLenum pname, GLint param);
    616 
    617     // Supported forms:
    618     // FIXME: should be union type
    619     // https://www.khronos.org/bugzilla/show_bug.cgi?id=1172
    620     [RaisesException] void texImage2D(
    621         GLenum target, GLint level, GLenum internalformat,
    622         GLsizei width, GLsizei height, GLint border,
    623         GLenum format, GLenum type, ArrayBufferView? pixels);
    624     [RaisesException] void texImage2D(
    625         GLenum target, GLint level, GLenum internalformat,
    626         GLenum format, GLenum type, ImageData? pixels);
    627     [RaisesException] void texImage2D(
    628         GLenum target, GLint level, GLenum internalformat,
    629         GLenum format, GLenum type, HTMLImageElement image);
    630     [RaisesException] void texImage2D(
    631         GLenum target, GLint level, GLenum internalformat,
    632         GLenum format, GLenum type, HTMLCanvasElement canvas);
    633     [RaisesException] void texImage2D(
    634         GLenum target, GLint level, GLenum internalformat,
    635         GLenum format, GLenum type, HTMLVideoElement video);
    636 
    637     [RaisesException] void texSubImage2D(
    638         GLenum target, GLint level, GLint xoffset, GLint yoffset,
    639         GLsizei width, GLsizei height,
    640         GLenum format, GLenum type, ArrayBufferView? pixels);
    641     [RaisesException] void texSubImage2D(
    642         GLenum target, GLint level, GLint xoffset, GLint yoffset,
    643         GLenum format, GLenum type, ImageData? pixels);
    644     [RaisesException] void texSubImage2D(
    645         GLenum target, GLint level, GLint xoffset, GLint yoffset,
    646         GLenum format, GLenum type, HTMLImageElement image);
    647     [RaisesException] void texSubImage2D(
    648         GLenum target, GLint level, GLint xoffset, GLint yoffset,
    649         GLenum format, GLenum type, HTMLCanvasElement canvas);
    650     [RaisesException] void texSubImage2D(
    651         GLenum target, GLint level, GLint xoffset, GLint yoffset,
    652         GLenum format, GLenum type, HTMLVideoElement video);
    653 
    654     void uniform1f(WebGLUniformLocation? location, GLfloat x);
    655     [Custom] void uniform1fv(WebGLUniformLocation? location, Float32Array v);
    656     void uniform1i(WebGLUniformLocation? location, GLint x);
    657     [Custom] void uniform1iv(WebGLUniformLocation? location, Int32Array v);
    658     void uniform2f(WebGLUniformLocation? location, GLfloat x, GLfloat y);
    659     [Custom] void uniform2fv(WebGLUniformLocation? location, Float32Array v);
    660     void uniform2i(WebGLUniformLocation? location, GLint x, GLint y);
    661     [Custom] void uniform2iv(WebGLUniformLocation? location, Int32Array v);
    662     void uniform3f(WebGLUniformLocation? location, GLfloat x, GLfloat y, GLfloat z);
    663     [Custom] void uniform3fv(WebGLUniformLocation? location, Float32Array v);
    664     void uniform3i(WebGLUniformLocation? location, GLint x, GLint y, GLint z);
    665     [Custom] void uniform3iv(WebGLUniformLocation? location, Int32Array v);
    666     void uniform4f(WebGLUniformLocation? location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
    667     [Custom] void uniform4fv(WebGLUniformLocation? location, Float32Array v);
    668     void uniform4i(WebGLUniformLocation? location, GLint x, GLint y, GLint z, GLint w);
    669     [Custom] void uniform4iv(WebGLUniformLocation? location, Int32Array v);
    670 
    671     [Custom] void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array array);
    672     [Custom] void uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array array);
    673     [Custom] void uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array array);
    674 
    675     void useProgram(WebGLProgram? program);
    676     void validateProgram(WebGLProgram? program);
    677 
    678     void vertexAttrib1f(GLuint indx, GLfloat x);
    679     [Custom] void vertexAttrib1fv(GLuint indx, Float32Array values);
    680     void vertexAttrib2f(GLuint indx, GLfloat x, GLfloat y);
    681     [Custom] void vertexAttrib2fv(GLuint indx, Float32Array values);
    682     void vertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
    683     [Custom] void vertexAttrib3fv(GLuint indx, Float32Array values);
    684     void vertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
    685     [Custom] void vertexAttrib4fv(GLuint indx, Float32Array values);
    686     void vertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized,
    687                              GLsizei stride, GLintptr offset);
    688 
    689     void viewport(GLint x, GLint y, GLsizei width, GLsizei height);
    690 };
    691