/*
 * Copyright (C) 2009 Apple Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

module html {

    interface [
        Conditional=WEBGL,
        InterfaceUUID=98fb48ae-7216-489c-862b-8e1217fc4443,
        ImplementationUUID=ab4f0781-152f-450e-9546-5b3987491a54,
        CustomMarkFunction,
        DontCheckEnums
    ] WebGLRenderingContext : CanvasRenderingContext {

        /* ClearBufferMask */
        const unsigned int DEPTH_BUFFER_BIT               = 0x00000100;
        const unsigned int STENCIL_BUFFER_BIT             = 0x00000400;
        const unsigned int COLOR_BUFFER_BIT               = 0x00004000;

        /* BeginMode */
        const unsigned int POINTS                         = 0x0000;
        const unsigned int LINES                          = 0x0001;
        const unsigned int LINE_LOOP                      = 0x0002;
        const unsigned int LINE_STRIP                     = 0x0003;
        const unsigned int TRIANGLES                      = 0x0004;
        const unsigned int TRIANGLE_STRIP                 = 0x0005;
        const unsigned int TRIANGLE_FAN                   = 0x0006;

        /* AlphaFunction (not supported in ES20) */
        /*      NEVER */
        /*      LESS */
        /*      EQUAL */
        /*      LEQUAL */
        /*      GREATER */
        /*      NOTEQUAL */
        /*      GEQUAL */
        /*      ALWAYS */

        /* BlendingFactorDest */
        const unsigned int ZERO                           = 0;
        const unsigned int ONE                            = 1;
        const unsigned int SRC_COLOR                      = 0x0300;
        const unsigned int ONE_MINUS_SRC_COLOR            = 0x0301;
        const unsigned int SRC_ALPHA                      = 0x0302;
        const unsigned int ONE_MINUS_SRC_ALPHA            = 0x0303;
        const unsigned int DST_ALPHA                      = 0x0304;
        const unsigned int ONE_MINUS_DST_ALPHA            = 0x0305;

        /* BlendingFactorSrc */
        /*      ZERO */
        /*      ONE */
        const unsigned int DST_COLOR                      = 0x0306;
        const unsigned int ONE_MINUS_DST_COLOR            = 0x0307;
        const unsigned int SRC_ALPHA_SATURATE             = 0x0308;
        /*      SRC_ALPHA */
        /*      ONE_MINUS_SRC_ALPHA */
        /*      DST_ALPHA */
        /*      ONE_MINUS_DST_ALPHA */

        /* BlendEquationSeparate */
        const unsigned int FUNC_ADD                       = 0x8006;
        const unsigned int BLEND_EQUATION                 = 0x8009;
        const unsigned int BLEND_EQUATION_RGB             = 0x8009;   /* same as BLEND_EQUATION */
        const unsigned int BLEND_EQUATION_ALPHA           = 0x883D;

        /* BlendSubtract */
        const unsigned int FUNC_SUBTRACT                  = 0x800A;
        const unsigned int FUNC_REVERSE_SUBTRACT          = 0x800B;

        /* Separate Blend Functions */
        const unsigned int BLEND_DST_RGB                  = 0x80C8;
        const unsigned int BLEND_SRC_RGB                  = 0x80C9;
        const unsigned int BLEND_DST_ALPHA                = 0x80CA;
        const unsigned int BLEND_SRC_ALPHA                = 0x80CB;
        const unsigned int CONSTANT_COLOR                 = 0x8001;
        const unsigned int ONE_MINUS_CONSTANT_COLOR       = 0x8002;
        const unsigned int CONSTANT_ALPHA                 = 0x8003;
        const unsigned int ONE_MINUS_CONSTANT_ALPHA       = 0x8004;
        const unsigned int BLEND_COLOR                    = 0x8005;

        /* Buffer Objects */
        const unsigned int ARRAY_BUFFER                   = 0x8892;
        const unsigned int ELEMENT_ARRAY_BUFFER           = 0x8893;
        const unsigned int ARRAY_BUFFER_BINDING           = 0x8894;
        const unsigned int ELEMENT_ARRAY_BUFFER_BINDING   = 0x8895;

        const unsigned int STREAM_DRAW                    = 0x88E0;
        const unsigned int STATIC_DRAW                    = 0x88E4;
        const unsigned int DYNAMIC_DRAW                   = 0x88E8;

        const unsigned int BUFFER_SIZE                    = 0x8764;
        const unsigned int BUFFER_USAGE                   = 0x8765;

        const unsigned int CURRENT_VERTEX_ATTRIB          = 0x8626;

        /* CullFaceMode */
        const unsigned int FRONT                          = 0x0404;
        const unsigned int BACK                           = 0x0405;
        const unsigned int FRONT_AND_BACK                 = 0x0408;

        /* DepthFunction */
        /*      NEVER */
        /*      LESS */
        /*      EQUAL */
        /*      LEQUAL */
        /*      GREATER */
        /*      NOTEQUAL */
        /*      GEQUAL */
        /*      ALWAYS */

        /* EnableCap */
        const unsigned int TEXTURE_2D                     = 0x0DE1;
        const unsigned int CULL_FACE                      = 0x0B44;
        const unsigned int BLEND                          = 0x0BE2;
        const unsigned int DITHER                         = 0x0BD0;
        const unsigned int STENCIL_TEST                   = 0x0B90;
        const unsigned int DEPTH_TEST                     = 0x0B71;
        const unsigned int SCISSOR_TEST                   = 0x0C11;
        const unsigned int POLYGON_OFFSET_FILL            = 0x8037;
        const unsigned int SAMPLE_ALPHA_TO_COVERAGE       = 0x809E;
        const unsigned int SAMPLE_COVERAGE                = 0x80A0;

        /* ErrorCode */
        const unsigned int NO_ERROR                       = 0;
        const unsigned int INVALID_ENUM                   = 0x0500;
        const unsigned int INVALID_VALUE                  = 0x0501;
        const unsigned int INVALID_OPERATION              = 0x0502;
        const unsigned int OUT_OF_MEMORY                  = 0x0505;

        /* FrontFaceDirection */
        const unsigned int CW                             = 0x0900;
        const unsigned int CCW                            = 0x0901;

        /* GetPName */
        const unsigned int LINE_WIDTH                     = 0x0B21;
        const unsigned int ALIASED_POINT_SIZE_RANGE       = 0x846D;
        const unsigned int ALIASED_LINE_WIDTH_RANGE       = 0x846E;
        const unsigned int CULL_FACE_MODE                 = 0x0B45;
        const unsigned int FRONT_FACE                     = 0x0B46;
        const unsigned int DEPTH_RANGE                    = 0x0B70;
        const unsigned int DEPTH_WRITEMASK                = 0x0B72;
        const unsigned int DEPTH_CLEAR_VALUE              = 0x0B73;
        const unsigned int DEPTH_FUNC                     = 0x0B74;
        const unsigned int STENCIL_CLEAR_VALUE            = 0x0B91;
        const unsigned int STENCIL_FUNC                   = 0x0B92;
        const unsigned int STENCIL_FAIL                   = 0x0B94;
        const unsigned int STENCIL_PASS_DEPTH_FAIL        = 0x0B95;
        const unsigned int STENCIL_PASS_DEPTH_PASS        = 0x0B96;
        const unsigned int STENCIL_REF                    = 0x0B97;
        const unsigned int STENCIL_VALUE_MASK             = 0x0B93;
        const unsigned int STENCIL_WRITEMASK              = 0x0B98;
        const unsigned int STENCIL_BACK_FUNC              = 0x8800;
        const unsigned int STENCIL_BACK_FAIL              = 0x8801;
        const unsigned int STENCIL_BACK_PASS_DEPTH_FAIL   = 0x8802;
        const unsigned int STENCIL_BACK_PASS_DEPTH_PASS   = 0x8803;
        const unsigned int STENCIL_BACK_REF               = 0x8CA3;
        const unsigned int STENCIL_BACK_VALUE_MASK        = 0x8CA4;
        const unsigned int STENCIL_BACK_WRITEMASK         = 0x8CA5;
        const unsigned int VIEWPORT                       = 0x0BA2;
        const unsigned int SCISSOR_BOX                    = 0x0C10;
        /*      SCISSOR_TEST */
        const unsigned int COLOR_CLEAR_VALUE              = 0x0C22;
        const unsigned int COLOR_WRITEMASK                = 0x0C23;
        const unsigned int UNPACK_ALIGNMENT               = 0x0CF5;
        const unsigned int PACK_ALIGNMENT                 = 0x0D05;
        const unsigned int MAX_TEXTURE_SIZE               = 0x0D33;
        const unsigned int MAX_VIEWPORT_DIMS              = 0x0D3A;
        const unsigned int SUBPIXEL_BITS                  = 0x0D50;
        const unsigned int RED_BITS                       = 0x0D52;
        const unsigned int GREEN_BITS                     = 0x0D53;
        const unsigned int BLUE_BITS                      = 0x0D54;
        const unsigned int ALPHA_BITS                     = 0x0D55;
        const unsigned int DEPTH_BITS                     = 0x0D56;
        const unsigned int STENCIL_BITS                   = 0x0D57;
        const unsigned int POLYGON_OFFSET_UNITS           = 0x2A00;
        /*      POLYGON_OFFSET_FILL */
        const unsigned int POLYGON_OFFSET_FACTOR          = 0x8038;
        const unsigned int TEXTURE_BINDING_2D             = 0x8069;
        const unsigned int SAMPLE_BUFFERS                 = 0x80A8;
        const unsigned int SAMPLES                        = 0x80A9;
        const unsigned int SAMPLE_COVERAGE_VALUE          = 0x80AA;
        const unsigned int SAMPLE_COVERAGE_INVERT         = 0x80AB;

        /* GetTextureParameter */
        /*      TEXTURE_MAG_FILTER */
        /*      TEXTURE_MIN_FILTER */
        /*      TEXTURE_WRAP_S */
        /*      TEXTURE_WRAP_T */

        const unsigned int NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2;
        const unsigned int COMPRESSED_TEXTURE_FORMATS     = 0x86A3;

        /* HintMode */
        const unsigned int DONT_CARE                      = 0x1100;
        const unsigned int FASTEST                        = 0x1101;
        const unsigned int NICEST                         = 0x1102;

        /* HintTarget */
        const unsigned int GENERATE_MIPMAP_HINT            = 0x8192;

        /* DataType */
        const unsigned int BYTE                           = 0x1400;
        const unsigned int UNSIGNED_BYTE                  = 0x1401;
        const unsigned int SHORT                          = 0x1402;
        const unsigned int UNSIGNED_SHORT                 = 0x1403;
        const unsigned int INT                            = 0x1404;
        const unsigned int UNSIGNED_INT                   = 0x1405;
        const unsigned int FLOAT                          = 0x1406;

        /* PixelFormat */
        const unsigned int DEPTH_COMPONENT                = 0x1902;
        const unsigned int ALPHA                          = 0x1906;
        const unsigned int RGB                            = 0x1907;
        const unsigned int RGBA                           = 0x1908;
        const unsigned int LUMINANCE                      = 0x1909;
        const unsigned int LUMINANCE_ALPHA                = 0x190A;

        /* PixelType */
        /*      UNSIGNED_BYTE */
        const unsigned int UNSIGNED_SHORT_4_4_4_4         = 0x8033;
        const unsigned int UNSIGNED_SHORT_5_5_5_1         = 0x8034;
        const unsigned int UNSIGNED_SHORT_5_6_5           = 0x8363;

        /* Shaders */
        const unsigned int FRAGMENT_SHADER                  = 0x8B30;
        const unsigned int VERTEX_SHADER                    = 0x8B31;
        const unsigned int MAX_VERTEX_ATTRIBS               = 0x8869;
        const unsigned int MAX_VERTEX_UNIFORM_VECTORS       = 0x8DFB;
        const unsigned int MAX_VARYING_VECTORS              = 0x8DFC;
        const unsigned int MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D;
        const unsigned int MAX_VERTEX_TEXTURE_IMAGE_UNITS   = 0x8B4C;
        const unsigned int MAX_TEXTURE_IMAGE_UNITS          = 0x8872;
        const unsigned int MAX_FRAGMENT_UNIFORM_VECTORS     = 0x8DFD;
        const unsigned int SHADER_TYPE                      = 0x8B4F;
        const unsigned int DELETE_STATUS                    = 0x8B80;
        const unsigned int LINK_STATUS                      = 0x8B82;
        const unsigned int VALIDATE_STATUS                  = 0x8B83;
        const unsigned int ATTACHED_SHADERS                 = 0x8B85;
        const unsigned int ACTIVE_UNIFORMS                  = 0x8B86;
        const unsigned int ACTIVE_ATTRIBUTES                = 0x8B89;
        const unsigned int SHADING_LANGUAGE_VERSION         = 0x8B8C;
        const unsigned int CURRENT_PROGRAM                  = 0x8B8D;

        /* StencilFunction */
        const unsigned int NEVER                          = 0x0200;
        const unsigned int LESS                           = 0x0201;
        const unsigned int EQUAL                          = 0x0202;
        const unsigned int LEQUAL                         = 0x0203;
        const unsigned int GREATER                        = 0x0204;
        const unsigned int NOTEQUAL                       = 0x0205;
        const unsigned int GEQUAL                         = 0x0206;
        const unsigned int ALWAYS                         = 0x0207;

        /* StencilOp */
        /*      ZERO */
        const unsigned int KEEP                           = 0x1E00;
        const unsigned int REPLACE                        = 0x1E01;
        const unsigned int INCR                           = 0x1E02;
        const unsigned int DECR                           = 0x1E03;
        const unsigned int INVERT                         = 0x150A;
        const unsigned int INCR_WRAP                      = 0x8507;
        const unsigned int DECR_WRAP                      = 0x8508;

        /* StringName */
        const unsigned int VENDOR                         = 0x1F00;
        const unsigned int RENDERER                       = 0x1F01;
        const unsigned int VERSION                        = 0x1F02;

        /* TextureMagFilter */
        const unsigned int NEAREST                        = 0x2600;
        const unsigned int LINEAR                         = 0x2601;

        /* TextureMinFilter */
        /*      NEAREST */
        /*      LINEAR */
        const unsigned int NEAREST_MIPMAP_NEAREST         = 0x2700;
        const unsigned int LINEAR_MIPMAP_NEAREST          = 0x2701;
        const unsigned int NEAREST_MIPMAP_LINEAR          = 0x2702;
        const unsigned int LINEAR_MIPMAP_LINEAR           = 0x2703;

        /* TextureParameterName */
        const unsigned int TEXTURE_MAG_FILTER             = 0x2800;
        const unsigned int TEXTURE_MIN_FILTER             = 0x2801;
        const unsigned int TEXTURE_WRAP_S                 = 0x2802;
        const unsigned int TEXTURE_WRAP_T                 = 0x2803;

        /* TextureTarget */
        /*      TEXTURE_2D */
        const unsigned int TEXTURE                        = 0x1702;

        const unsigned int TEXTURE_CUBE_MAP               = 0x8513;
        const unsigned int TEXTURE_BINDING_CUBE_MAP       = 0x8514;
        const unsigned int TEXTURE_CUBE_MAP_POSITIVE_X    = 0x8515;
        const unsigned int TEXTURE_CUBE_MAP_NEGATIVE_X    = 0x8516;
        const unsigned int TEXTURE_CUBE_MAP_POSITIVE_Y    = 0x8517;
        const unsigned int TEXTURE_CUBE_MAP_NEGATIVE_Y    = 0x8518;
        const unsigned int TEXTURE_CUBE_MAP_POSITIVE_Z    = 0x8519;
        const unsigned int TEXTURE_CUBE_MAP_NEGATIVE_Z    = 0x851A;
        const unsigned int MAX_CUBE_MAP_TEXTURE_SIZE      = 0x851C;

        /* TextureUnit */
        const unsigned int TEXTURE0                       = 0x84C0;
        const unsigned int TEXTURE1                       = 0x84C1;
        const unsigned int TEXTURE2                       = 0x84C2;
        const unsigned int TEXTURE3                       = 0x84C3;
        const unsigned int TEXTURE4                       = 0x84C4;
        const unsigned int TEXTURE5                       = 0x84C5;
        const unsigned int TEXTURE6                       = 0x84C6;
        const unsigned int TEXTURE7                       = 0x84C7;
        const unsigned int TEXTURE8                       = 0x84C8;
        const unsigned int TEXTURE9                       = 0x84C9;
        const unsigned int TEXTURE10                      = 0x84CA;
        const unsigned int TEXTURE11                      = 0x84CB;
        const unsigned int TEXTURE12                      = 0x84CC;
        const unsigned int TEXTURE13                      = 0x84CD;
        const unsigned int TEXTURE14                      = 0x84CE;
        const unsigned int TEXTURE15                      = 0x84CF;
        const unsigned int TEXTURE16                      = 0x84D0;
        const unsigned int TEXTURE17                      = 0x84D1;
        const unsigned int TEXTURE18                      = 0x84D2;
        const unsigned int TEXTURE19                      = 0x84D3;
        const unsigned int TEXTURE20                      = 0x84D4;
        const unsigned int TEXTURE21                      = 0x84D5;
        const unsigned int TEXTURE22                      = 0x84D6;
        const unsigned int TEXTURE23                      = 0x84D7;
        const unsigned int TEXTURE24                      = 0x84D8;
        const unsigned int TEXTURE25                      = 0x84D9;
        const unsigned int TEXTURE26                      = 0x84DA;
        const unsigned int TEXTURE27                      = 0x84DB;
        const unsigned int TEXTURE28                      = 0x84DC;
        const unsigned int TEXTURE29                      = 0x84DD;
        const unsigned int TEXTURE30                      = 0x84DE;
        const unsigned int TEXTURE31                      = 0x84DF;
        const unsigned int ACTIVE_TEXTURE                 = 0x84E0;

        /* TextureWrapMode */
        const unsigned int REPEAT                         = 0x2901;
        const unsigned int CLAMP_TO_EDGE                  = 0x812F;
        const unsigned int MIRRORED_REPEAT                = 0x8370;

        /* Uniform Types */
        const unsigned int FLOAT_VEC2                     = 0x8B50;
        const unsigned int FLOAT_VEC3                     = 0x8B51;
        const unsigned int FLOAT_VEC4                     = 0x8B52;
        const unsigned int INT_VEC2                       = 0x8B53;
        const unsigned int INT_VEC3                       = 0x8B54;
        const unsigned int INT_VEC4                       = 0x8B55;
        const unsigned int BOOL                           = 0x8B56;
        const unsigned int BOOL_VEC2                      = 0x8B57;
        const unsigned int BOOL_VEC3                      = 0x8B58;
        const unsigned int BOOL_VEC4                      = 0x8B59;
        const unsigned int FLOAT_MAT2                     = 0x8B5A;
        const unsigned int FLOAT_MAT3                     = 0x8B5B;
        const unsigned int FLOAT_MAT4                     = 0x8B5C;
        const unsigned int SAMPLER_2D                     = 0x8B5E;
        const unsigned int SAMPLER_CUBE                   = 0x8B60;

        /* Vertex Arrays */
        const unsigned int VERTEX_ATTRIB_ARRAY_ENABLED        = 0x8622;
        const unsigned int VERTEX_ATTRIB_ARRAY_SIZE           = 0x8623;
        const unsigned int VERTEX_ATTRIB_ARRAY_STRIDE         = 0x8624;
        const unsigned int VERTEX_ATTRIB_ARRAY_TYPE           = 0x8625;
        const unsigned int VERTEX_ATTRIB_ARRAY_NORMALIZED     = 0x886A;
        const unsigned int VERTEX_ATTRIB_ARRAY_POINTER        = 0x8645;
        const unsigned int VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F;

        /* Shader Source */
        const unsigned int COMPILE_STATUS                 = 0x8B81;
        const unsigned int SHADER_COMPILER                = 0x8DFA;

        /* Shader Precision-Specified Types */
        const unsigned int LOW_FLOAT                      = 0x8DF0;
        const unsigned int MEDIUM_FLOAT                   = 0x8DF1;
        const unsigned int HIGH_FLOAT                     = 0x8DF2;
        const unsigned int LOW_INT                        = 0x8DF3;
        const unsigned int MEDIUM_INT                     = 0x8DF4;
        const unsigned int HIGH_INT                       = 0x8DF5;

        /* Framebuffer Object. */
        const unsigned int FRAMEBUFFER                    = 0x8D40;
        const unsigned int RENDERBUFFER                   = 0x8D41;

        const unsigned int RGBA4                          = 0x8056;
        const unsigned int RGB5_A1                        = 0x8057;
        const unsigned int RGB565                         = 0x8D62;
        const unsigned int DEPTH_COMPONENT16              = 0x81A5;
        const unsigned int STENCIL_INDEX                  = 0x1901;
        const unsigned int STENCIL_INDEX8                 = 0x8D48;
        const unsigned int DEPTH_STENCIL                  = 0x84F9;

        const unsigned int RENDERBUFFER_WIDTH             = 0x8D42;
        const unsigned int RENDERBUFFER_HEIGHT            = 0x8D43;
        const unsigned int RENDERBUFFER_INTERNAL_FORMAT   = 0x8D44;
        const unsigned int RENDERBUFFER_RED_SIZE          = 0x8D50;
        const unsigned int RENDERBUFFER_GREEN_SIZE        = 0x8D51;
        const unsigned int RENDERBUFFER_BLUE_SIZE         = 0x8D52;
        const unsigned int RENDERBUFFER_ALPHA_SIZE        = 0x8D53;
        const unsigned int RENDERBUFFER_DEPTH_SIZE        = 0x8D54;
        const unsigned int RENDERBUFFER_STENCIL_SIZE      = 0x8D55;

        const unsigned int FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE           = 0x8CD0;
        const unsigned int FRAMEBUFFER_ATTACHMENT_OBJECT_NAME           = 0x8CD1;
        const unsigned int FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL         = 0x8CD2;
        const unsigned int FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3;

        const unsigned int COLOR_ATTACHMENT0              = 0x8CE0;
        const unsigned int DEPTH_ATTACHMENT               = 0x8D00;
        const unsigned int STENCIL_ATTACHMENT             = 0x8D20;
        const unsigned int DEPTH_STENCIL_ATTACHMENT       = 0x821A;

        const unsigned int NONE                           = 0;

        const unsigned int FRAMEBUFFER_COMPLETE                      = 0x8CD5;
        const unsigned int FRAMEBUFFER_INCOMPLETE_ATTACHMENT         = 0x8CD6;
        const unsigned int FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7;
        const unsigned int FRAMEBUFFER_INCOMPLETE_DIMENSIONS         = 0x8CD9;
        const unsigned int FRAMEBUFFER_UNSUPPORTED                   = 0x8CDD;

        const unsigned int FRAMEBUFFER_BINDING            = 0x8CA6;
        const unsigned int RENDERBUFFER_BINDING           = 0x8CA7;
        const unsigned int MAX_RENDERBUFFER_SIZE          = 0x84E8;

        const unsigned int INVALID_FRAMEBUFFER_OPERATION  = 0x0506;

        /* WebGL-specific enums */
        const unsigned int UNPACK_FLIP_Y_WEBGL                = 0x9240;
        const unsigned int UNPACK_PREMULTIPLY_ALPHA_WEBGL     = 0x9241;
        const unsigned int CONTEXT_LOST_WEBGL                 = 0x9242;
        const unsigned int UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243;
        const unsigned int BROWSER_DEFAULT_WEBGL              = 0x9244;

        [StrictTypeChecking] void         activeTexture(in unsigned long texture) raises(DOMException);
        [StrictTypeChecking] void         attachShader(in WebGLProgram program, in WebGLShader shader) raises(DOMException);
        [StrictTypeChecking] void         bindAttribLocation(in WebGLProgram program, in unsigned long index, in DOMString name) raises(DOMException);
        [StrictTypeChecking] void         bindBuffer(in unsigned long target, in WebGLBuffer buffer) raises(DOMException);
        [StrictTypeChecking] void         bindFramebuffer(in unsigned long target, in WebGLFramebuffer framebuffer) raises(DOMException);
        [StrictTypeChecking] void         bindRenderbuffer(in unsigned long target, in WebGLRenderbuffer renderbuffer) raises(DOMException);
        [StrictTypeChecking] void         bindTexture(in unsigned long target, in WebGLTexture texture) raises(DOMException);
        [StrictTypeChecking] void         blendColor(in float red, in float green, in float blue, in float alpha);
        [StrictTypeChecking] void         blendEquation( in unsigned long mode );
        [StrictTypeChecking] void         blendEquationSeparate(in unsigned long modeRGB, in unsigned long modeAlpha);
        [StrictTypeChecking] void         blendFunc(in unsigned long sfactor, in unsigned long dfactor);
        [StrictTypeChecking] void         blendFuncSeparate(in unsigned long srcRGB, in unsigned long dstRGB, in unsigned long srcAlpha, in unsigned long dstAlpha);
        [StrictTypeChecking] void         bufferData(in unsigned long target, in ArrayBuffer data, in unsigned long usage) raises (DOMException);
        [StrictTypeChecking] void         bufferData(in unsigned long target, in ArrayBufferView data, in unsigned long usage) raises (DOMException);
        [StrictTypeChecking] void         bufferData(in unsigned long target, in long size, in unsigned long usage) raises (DOMException);
        [StrictTypeChecking] void         bufferSubData(in unsigned long target, in long offset, in ArrayBuffer data) raises (DOMException);
        [StrictTypeChecking] void         bufferSubData(in unsigned long target, in long offset, in ArrayBufferView data) raises (DOMException);

        [StrictTypeChecking] unsigned long checkFramebufferStatus(in unsigned long target);
        [StrictTypeChecking] void         clear(in unsigned long mask);
        [StrictTypeChecking] void         clearColor(in float red, in float green, in float blue, in float alpha);
        [StrictTypeChecking] void         clearDepth(in float depth);
        [StrictTypeChecking] void         clearStencil(in long s);
        [StrictTypeChecking] void         colorMask(in boolean red, in boolean green, in boolean blue, in boolean alpha);
        [StrictTypeChecking] void         compileShader(in WebGLShader shader) raises(DOMException);
        
        //void         compressedTexImage2D(in unsigned long target, in long level, in unsigned long internalformat, in unsigned long width, in unsigned long height, in long border, in unsigned long imageSize, const void* data);
        //void         compressedTexSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset, in unsigned long width, in unsigned long height, in unsigned long format, in unsigned long imageSize, const void* data);
        
        [StrictTypeChecking] void         copyTexImage2D(in unsigned long target, in long level, in unsigned long internalformat, in long x, in long y, in long width, in long height, in long border);
        [StrictTypeChecking] void         copyTexSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset, in long x, in long y, in long width, in long height);

        [StrictTypeChecking] WebGLBuffer createBuffer();
        [StrictTypeChecking] WebGLFramebuffer createFramebuffer();
        [StrictTypeChecking] WebGLProgram createProgram();
        [StrictTypeChecking] WebGLRenderbuffer createRenderbuffer();
        [StrictTypeChecking] WebGLShader createShader(in unsigned long type) raises(DOMException);
        [StrictTypeChecking] WebGLTexture createTexture();

        [StrictTypeChecking] void         cullFace(in unsigned long mode);

        [StrictTypeChecking] void         deleteBuffer(in WebGLBuffer buffer);
        [StrictTypeChecking] void         deleteFramebuffer(in WebGLFramebuffer framebuffer);
        [StrictTypeChecking] void         deleteProgram(in WebGLProgram program);
        [StrictTypeChecking] void         deleteRenderbuffer(in WebGLRenderbuffer renderbuffer);
        [StrictTypeChecking] void         deleteShader(in WebGLShader shader);
        [StrictTypeChecking] void         deleteTexture(in WebGLTexture texture);

        [StrictTypeChecking] void         depthFunc(in unsigned long func);
        [StrictTypeChecking] void         depthMask(in boolean flag);
        // FIXME: this differs from the current WebGL spec (depthRangef)
        [StrictTypeChecking] void         depthRange(in float zNear, in float zFar);
        [StrictTypeChecking] void         detachShader(in WebGLProgram program, in WebGLShader shader) raises(DOMException);
        [StrictTypeChecking] void         disable(in unsigned long cap);
        [StrictTypeChecking] void         disableVertexAttribArray(in unsigned long index) raises(DOMException);
        [StrictTypeChecking] void         drawArrays(in unsigned long mode, in long first, in long count) raises(DOMException);
        [StrictTypeChecking] void         drawElements(in unsigned long mode, in long count, in unsigned long type, in long offset) raises(DOMException);

        [StrictTypeChecking] void         enable(in unsigned long cap);
        [StrictTypeChecking] void         enableVertexAttribArray(in unsigned long index) raises(DOMException);
        [StrictTypeChecking] void         finish();
        [StrictTypeChecking] void         flush();
        [StrictTypeChecking] void         framebufferRenderbuffer(in unsigned long target, in unsigned long attachment, in unsigned long renderbuffertarget, in WebGLRenderbuffer renderbuffer) raises(DOMException);
        [StrictTypeChecking] void         framebufferTexture2D(in unsigned long target, in unsigned long attachment, in unsigned long textarget, in WebGLTexture texture, in long level) raises(DOMException);
        [StrictTypeChecking] void         frontFace(in unsigned long mode);
        [StrictTypeChecking] void         generateMipmap(in unsigned long target);
        
        [StrictTypeChecking] WebGLActiveInfo getActiveAttrib(in WebGLProgram program, in unsigned long index) raises (DOMException);
        [StrictTypeChecking] WebGLActiveInfo getActiveUniform(in WebGLProgram program, in unsigned long index) raises (DOMException);

        [StrictTypeChecking, Custom] void getAttachedShaders(in WebGLProgram program) raises (DOMException);

        [StrictTypeChecking] int          getAttribLocation(in WebGLProgram program, in DOMString name);

        // any getBufferParameter(in unsigned long target, in unsigned long pname) raises(DOMException);
        [StrictTypeChecking, Custom] void getBufferParameter();

        [StrictTypeChecking] WebGLContextAttributes getContextAttributes();

        [StrictTypeChecking] unsigned long getError();

        // object getExtension(in DOMString name);
        [StrictTypeChecking, Custom] void getExtension(in DOMString name);

        // any getFramebufferAttachmentParameter(in unsigned long target, in unsigned long attachment, in unsigned long pname) raises(DOMException);
        [StrictTypeChecking, Custom] void getFramebufferAttachmentParameter();
        // any getParameter(in unsigned long pname) raises(DOMException);
        [StrictTypeChecking, Custom] void getParameter();
        // any getProgramParameter(in WebGLProgram program, in unsigned long pname) raises(DOMException);
        [StrictTypeChecking, Custom] void getProgramParameter();
        [StrictTypeChecking, ConvertNullStringTo=Null] DOMString getProgramInfoLog(in WebGLProgram program) raises(DOMException);
        // any getRenderbufferParameter(in unsigned long target, in unsigned long pname) raises(DOMException);
        [StrictTypeChecking, Custom] void getRenderbufferParameter();
        // any getShaderParameter(in WebGLShader shader, in unsigned long pname) raises(DOMException);
        [StrictTypeChecking, Custom] void getShaderParameter() raises(DOMException);

        [StrictTypeChecking, ConvertNullStringTo=Null] DOMString    getShaderInfoLog(in WebGLShader shader) raises(DOMException);

        // TBD
        // void glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);

        [StrictTypeChecking, ConvertNullStringTo=Null] DOMString    getShaderSource(in WebGLShader shader) raises(DOMException);

        // DOMString[] getSupportedExtensions()
        [StrictTypeChecking, Custom] void getSupportedExtensions();

        // any getTexParameter(in unsigned long target, in unsigned long pname) raises(DOMException);
        [StrictTypeChecking, Custom] void getTexParameter();

        // any getUniform(in WebGLProgram program, in WebGLUniformLocation location) raises(DOMException);
        [StrictTypeChecking, Custom] void getUniform();

        [StrictTypeChecking] WebGLUniformLocation getUniformLocation(in WebGLProgram program, in DOMString name) raises(DOMException);

        // any getVertexAttrib(in unsigned long index, in unsigned long pname) raises(DOMException);
        [StrictTypeChecking, Custom] void getVertexAttrib();

        [StrictTypeChecking] long getVertexAttribOffset(in unsigned long index, in unsigned long pname);

        [StrictTypeChecking] void         hint(in unsigned long target, in unsigned long mode);
        [StrictTypeChecking] boolean      isBuffer(in WebGLBuffer buffer);
        [StrictTypeChecking] boolean      isContextLost();
        [StrictTypeChecking] boolean      isEnabled(in unsigned long cap);
        [StrictTypeChecking] boolean      isFramebuffer(in WebGLFramebuffer framebuffer);
        [StrictTypeChecking] boolean      isProgram(in WebGLProgram program);
        [StrictTypeChecking] boolean      isRenderbuffer(in WebGLRenderbuffer renderbuffer);
        [StrictTypeChecking] boolean      isShader(in WebGLShader shader);
        [StrictTypeChecking] boolean      isTexture(in WebGLTexture texture);
        [StrictTypeChecking] void         lineWidth(in float width);
        [StrictTypeChecking] void         linkProgram(in WebGLProgram program) raises(DOMException);
        [StrictTypeChecking] void         pixelStorei(in unsigned long pname, in long param);
        [StrictTypeChecking] void         polygonOffset(in float factor, in float units);

        [StrictTypeChecking] void         readPixels(in long x, in long y, in long width, in long height, in unsigned long format, in unsigned long type, in ArrayBufferView pixels) raises(DOMException);
        
        [StrictTypeChecking] void         releaseShaderCompiler();
        [StrictTypeChecking] void         renderbufferStorage(in unsigned long target, in unsigned long internalformat, in long width, in long height);
        [StrictTypeChecking] void         sampleCoverage(in float value, in boolean invert);
        [StrictTypeChecking] void         scissor(in long x, in long y, in long width, in long height);
        [StrictTypeChecking] void         shaderSource(in WebGLShader shader, in DOMString string) raises(DOMException);
        [StrictTypeChecking] void         stencilFunc(in unsigned long func, in long ref, in unsigned long mask);
        [StrictTypeChecking] void         stencilFuncSeparate(in unsigned long face, in unsigned long func, in long ref, in unsigned long mask);
        [StrictTypeChecking] void         stencilMask(in unsigned long mask);
        [StrictTypeChecking] void         stencilMaskSeparate(in unsigned long face, in unsigned long mask);
        [StrictTypeChecking] void         stencilOp(in unsigned long fail, in unsigned long zfail, in unsigned long zpass);
        [StrictTypeChecking] void         stencilOpSeparate(in unsigned long face, in unsigned long fail, in unsigned long zfail, in unsigned long zpass);

        [StrictTypeChecking] void         texParameterf(in unsigned long target, in unsigned long pname, in float param);
        [StrictTypeChecking] void         texParameteri(in unsigned long target, in unsigned long pname, in long param);

        // Supported forms:
        [StrictTypeChecking] void         texImage2D(in unsigned long target, in long level, in unsigned long internalformat, in long width, in long height, 
                                                     in long border, in unsigned long format, in unsigned long type, in ArrayBufferView pixels) raises (DOMException);
        [StrictTypeChecking] void         texImage2D(in unsigned long target, in long level, in unsigned long internalformat,
                                                     in unsigned long format, in unsigned long type, in ImageData pixels) raises (DOMException);
        [StrictTypeChecking] void         texImage2D(in unsigned long target, in long level, in unsigned long internalformat,
                                                     in unsigned long format, in unsigned long type, in HTMLImageElement image) raises (DOMException);
        [StrictTypeChecking] void         texImage2D(in unsigned long target, in long level, in unsigned long internalformat,
                                                     in unsigned long format, in unsigned long type, in HTMLCanvasElement canvas) raises (DOMException);
#if defined(ENABLE_VIDEO) && ENABLE_VIDEO
        [StrictTypeChecking] void         texImage2D(in unsigned long target, in long level, in unsigned long internalformat,
                                                     in unsigned long format, in unsigned long type, in HTMLVideoElement video) raises (DOMException);
#endif

        [StrictTypeChecking] void         texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset, 
                                                        in long width, in long height, 
                                                        in unsigned long format, in unsigned long type, in ArrayBufferView pixels) raises (DOMException);
        [StrictTypeChecking] void         texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
                                                        in unsigned long format, in unsigned long type, in ImageData pixels) raises (DOMException);
        [StrictTypeChecking] void         texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
                                                        in unsigned long format, in unsigned long type, in HTMLImageElement image) raises (DOMException);
        [StrictTypeChecking] void         texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
                                                        in unsigned long format, in unsigned long type, in HTMLCanvasElement canvas) raises (DOMException);
#if defined(ENABLE_VIDEO) && ENABLE_VIDEO
        [StrictTypeChecking] void         texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
                                                        in unsigned long format, in unsigned long type, in HTMLVideoElement video) raises (DOMException);
#endif

        [StrictTypeChecking] void uniform1f(in WebGLUniformLocation location, in float x) raises(DOMException);
        [StrictTypeChecking, Custom] void uniform1fv(in WebGLUniformLocation location, in Float32Array v) raises(DOMException);
        [StrictTypeChecking] void uniform1i(in WebGLUniformLocation location, in long x) raises(DOMException);
        [StrictTypeChecking, Custom] void uniform1iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);
        [StrictTypeChecking] void uniform2f(in WebGLUniformLocation location, in float x, in float y) raises(DOMException);
        [StrictTypeChecking, Custom] void uniform2fv(in WebGLUniformLocation location, in Float32Array v) raises(DOMException);
        [StrictTypeChecking] void uniform2i(in WebGLUniformLocation location, in long x, in long y) raises(DOMException);
        [StrictTypeChecking, Custom] void uniform2iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);
        [StrictTypeChecking] void uniform3f(in WebGLUniformLocation location, in float x, in float y, in float z) raises(DOMException);
        [StrictTypeChecking, Custom] void uniform3fv(in WebGLUniformLocation location, in Float32Array v) raises(DOMException);
        [StrictTypeChecking] void uniform3i(in WebGLUniformLocation location, in long x, in long y, in long z) raises(DOMException);
        [StrictTypeChecking, Custom] void uniform3iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);
        [StrictTypeChecking] void uniform4f(in WebGLUniformLocation location, in float x, in float y, in float z, in float w) raises(DOMException);
        [StrictTypeChecking, Custom] void uniform4fv(in WebGLUniformLocation location, in Float32Array v) raises(DOMException);
        [StrictTypeChecking] void uniform4i(in WebGLUniformLocation location, in long x, in long y, in long z, in long w) raises(DOMException);
        [StrictTypeChecking, Custom] void uniform4iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);

        [StrictTypeChecking, Custom] void uniformMatrix2fv(in WebGLUniformLocation location, in boolean transpose, in Float32Array array) raises(DOMException);
        [StrictTypeChecking, Custom] void uniformMatrix3fv(in WebGLUniformLocation location, in boolean transpose, in Float32Array array) raises(DOMException);
        [StrictTypeChecking, Custom] void uniformMatrix4fv(in WebGLUniformLocation location, in boolean transpose, in Float32Array array) raises(DOMException);

        [StrictTypeChecking] void         useProgram(in WebGLProgram program) raises(DOMException);
        [StrictTypeChecking] void         validateProgram(in WebGLProgram program) raises(DOMException);

        [StrictTypeChecking] void         vertexAttrib1f(in unsigned long indx, in float x);
        [StrictTypeChecking, Custom] void         vertexAttrib1fv(in unsigned long indx, in Float32Array values);
        [StrictTypeChecking] void         vertexAttrib2f(in unsigned long indx, in float x, in float y);
        [StrictTypeChecking, Custom] void         vertexAttrib2fv(in unsigned long indx, in Float32Array values);
        [StrictTypeChecking] void         vertexAttrib3f(in unsigned long indx, in float x, in float y, in float z);
        [StrictTypeChecking, Custom] void         vertexAttrib3fv(in unsigned long indx, in Float32Array values);
        [StrictTypeChecking] void         vertexAttrib4f(in unsigned long indx, in float x, in float y, in float z, in float w);
        [StrictTypeChecking, Custom] void         vertexAttrib4fv(in unsigned long indx, in Float32Array values);
        [StrictTypeChecking] void         vertexAttribPointer(in unsigned long indx, in long size, in unsigned long type, in boolean normalized, 
                                                              in long stride, in long offset) raises(DOMException);

        [StrictTypeChecking] void         viewport(in long x, in long y, in long width, in long height);
    };
}

