Skip to content

Instantly share code, notes, and snippets.

@okuoku
Last active December 16, 2020 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okuoku/fe88a3c390bab4a0678283ecd8deee7e to your computer and use it in GitHub Desktop.
Save okuoku/fe88a3c390bab4a0678283ecd8deee7e to your computer and use it in GitHub Desktop.
typedef unsigned long GLenum;
typedef boolean GLboolean;
typedef unsigned long GLbitfield;
typedef byte GLbyte; /* 'byte' should be a signed 8 bit type. */
typedef short GLshort;
typedef long GLint;
typedef long GLsizei;
typedef long long GLintptr;
typedef long long GLsizeiptr;
typedef octet GLubyte; /* 'octet' should be an unsigned 8 bit type. */
typedef unsigned short GLushort;
typedef unsigned long GLuint;
typedef unrestricted float GLfloat;
typedef unrestricted float GLclampf;
dictionary WebGLContextAttributes { /* Bitmap flags */ }
interface WebGLObject { };
interface WebGLBuffer : WebGLObject { };
interface WebGLFramebuffer : WebGLObject { };
interface WebGLProgram : WebGLObject { };
interface WebGLRenderbuffer : WebGLObject { };
interface WebGLShader : WebGLObject { };
interface WebGLTexture : WebGLObject { };
interface WebGLUniformLocation { };
interface WebGLActiveInfo {
readonly attribute GLint size;
readonly attribute GLenum type;
readonly attribute DOMString name;
};
interface WebGLShaderPrecisionFormat {
readonly attribute GLint rangeMin;
readonly attribute GLint rangeMax;
readonly attribute GLint precision;
};
typedef (ImageData or HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) TexImageSource;
/* Context properties */
readonly attribute HTMLCanvasElement canvas;
readonly attribute GLsizei drawingBufferWidth;
readonly attribute GLsizei drawingBufferHeight;
/* Context, Platform */
WebGLContextAttributes? getContextAttributes();
boolean isContextLost();
sequence<DOMString>? getSupportedExtensions();
object? getExtension(DOMString name);
/* Context readback */
/* Handles */
/* OpenGL State */
void disable(GLenum cap); // NOT Located
void enable(GLenum cap); // NOT Located
/* Programs */
/* Rasterizer control */
/* Buffer / Textures */
typedef (ArrayBuffer or ArrayBufferView) BufferDataSource;
/* Fragment */
/* Framebuffer/Renderbuffer */
/* HW Clear */
/* Drawcall etc */
// 2.5 GL Errors
GLenum getError();
// 2.7 Current Vertex State
void vertexAttrib1f(GLuint indx, GLfloat x);
void vertexAttrib1fv(GLuint indx, Float32Array values);
void vertexAttrib1fv(GLuint indx, sequence<GLfloat> values);
void vertexAttrib2f(GLuint indx, GLfloat x, GLfloat y);
void vertexAttrib2fv(GLuint indx, Float32Array values);
void vertexAttrib2fv(GLuint indx, sequence<GLfloat> values);
void vertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
void vertexAttrib3fv(GLuint indx, Float32Array values);
void vertexAttrib3fv(GLuint indx, sequence<GLfloat> values);
void vertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void vertexAttrib4fv(GLuint indx, Float32Array values);
void vertexAttrib4fv(GLuint indx, sequence<GLfloat> values);
// 2.8 Vertex Arrays
void vertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset);
void enableVertexAttribArray(GLuint index);
void disableVertexAttribArray(GLuint index);
void drawArrays(GLenum mode, GLint first, GLsizei count);
void drawElements(GLenum mode, GLsizei count, GLenum type, GLintptr offset);
// 2.9 Buffer Objects
void bindBuffer(GLenum target, WebGLBuffer? buffer);
void deleteBuffer(WebGLBuffer? buffer);
WebGLBuffer? createBuffer(); // genBuffers
void bufferData(GLenum target, GLsizeiptr size, GLenum usage);
void bufferData(GLenum target, BufferDataSource? data, GLenum usage);
void bufferSubData(GLenum target, GLintptr offset, BufferDataSource? data);
// 2.10 Vertex shaders
// 2.10.1 Loading and Creating Shader Source
// missing: ReleaseShaderCompiler
WebGLShader? createShader(GLenum type);
void shaderSource(WebGLShader? shader, DOMString source);
void compileShader(WebGLShader? shader);
void deleteShader(WebGLShader? shader);
// 2.10.3 Program Objects
WebGLProgram? createProgram();
void attachShader(WebGLProgram? program, WebGLShader? shader);
void detachShader(WebGLProgram? program, WebGLShader? shader);
void linkProgram(WebGLProgram? program);
void useProgram(WebGLProgram? program);
void deleteProgram(WebGLProgram? program);
// 2.10.4 Shader Variables
WebGLActiveInfo? getActiveAttrib(WebGLProgram? program, GLuint index);
GLint getAttribLocation(WebGLProgram? program, DOMString name);
void bindAttribLocation(WebGLProgram? program, GLuint index, DOMString name);
WebGLUniformLocation? getUniformLocation(WebGLProgram? program, DOMString name);
WebGLActiveInfo? getActiveUniform(WebGLProgram? program, GLuint index);
void uniform1f(WebGLUniformLocation? location, GLfloat x);
void uniform1fv(WebGLUniformLocation? location, Float32Array v);
void uniform1fv(WebGLUniformLocation? location, sequence<GLfloat> v);
void uniform1i(WebGLUniformLocation? location, GLint x);
void uniform1iv(WebGLUniformLocation? location, Int32Array v);
void uniform1iv(WebGLUniformLocation? location, sequence<long> v);
void uniform2f(WebGLUniformLocation? location, GLfloat x, GLfloat y);
void uniform2fv(WebGLUniformLocation? location, Float32Array v);
void uniform2fv(WebGLUniformLocation? location, sequence<GLfloat> v);
void uniform2i(WebGLUniformLocation? location, GLint x, GLint y);
void uniform2iv(WebGLUniformLocation? location, Int32Array v);
void uniform2iv(WebGLUniformLocation? location, sequence<long> v);
void uniform3f(WebGLUniformLocation? location, GLfloat x, GLfloat y, GLfloat z);
void uniform3fv(WebGLUniformLocation? location, Float32Array v);
void uniform3fv(WebGLUniformLocation? location, sequence<GLfloat> v);
void uniform3i(WebGLUniformLocation? location, GLint x, GLint y, GLint z);
void uniform3iv(WebGLUniformLocation? location, Int32Array v);
void uniform3iv(WebGLUniformLocation? location, sequence<long> v);
void uniform4f(WebGLUniformLocation? location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void uniform4fv(WebGLUniformLocation? location, Float32Array v);
void uniform4fv(WebGLUniformLocation? location, sequence<GLfloat> v);
void uniform4i(WebGLUniformLocation? location, GLint x, GLint y, GLint z, GLint w);
void uniform4iv(WebGLUniformLocation? location, Int32Array v);
void uniform4iv(WebGLUniformLocation? location, sequence<long> v);
void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array value);
void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, sequence<GLfloat> value);
void uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array value);
void uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose, sequence<GLfloat> value);
void uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array value);
void uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose, sequence<GLfloat> value);
// 2.10.5 Shader Execution
void validateProgram(WebGLProgram? program);
// 2.12.1 Controlling the Viewport
void depthRange(GLclampf zNear, GLclampf zFar);
void viewport(GLint x, GLint y, GLsizei width, GLsizei height);
// 3.4 Line Segments
void lineWidth(GLfloat width);
// 3.5 Polygons
void frontFace(GLenum mode);
void cullFace(GLenum mode);
// 3.5.2 Depth offset
void polygonOffset(GLfloat factor, GLfloat units);
// 3.6.1 Pixel Storage Modes
void pixelStorei(GLenum pname, GLint param);
// 3.7 Texturing
void activeTexture(GLenum texture);
// 3.7.1 Texture Image Specification
void texImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ArrayBufferView? pixels);
void texImage2D(GLenum target, GLint level, GLenum internalformat, GLenum format, GLenum type, TexImageSource? source); // May throw DOMException
// 3.7.2 Alternate Texture Image Specification Commands
void copyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, ArrayBufferView? pixels);
void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, TexImageSource? source); // May throw DOMException
void copyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
// 3.7.3 Compressed Texture Images
void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, ArrayBufferView data);
void compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, ArrayBufferView data);
// 3.7.4 Texture Parameters
void texParameterf(GLenum target, GLenum pname, GLfloat param);
void texParameteri(GLenum target, GLenum pname, GLint param);
// 3.7.11 Mipmap Generation
void generateMipmap(GLenum target);
// 3.7.13 Texture Objects
void bindTexture(GLenum target, WebGLTexture? texture);
void deleteTexture(WebGLTexture? texture);
WebGLTexture? createTexture(); // GenTextures
// 4.1.2 Scissor Test
void scissor(GLint x, GLint y, GLsizei width, GLsizei height);
// 4.1.3 Multisample Fragment Operations
void sampleCoverage(GLclampf value, GLboolean invert);
// 4.1.4 Stencil Test
void stencilFunc(GLenum func, GLint ref, GLuint mask);
void stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
void stencilOp(GLenum fail, GLenum zfail, GLenum zpass);
void stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
// 4.1.5 Depth Buffer Test
void depthFunc(GLenum func);
// 4.1.6 Blending
void blendEquation(GLenum mode);
void blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
void blendFunc(GLenum sfactor, GLenum dfactor);
void blendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
// 4.2.2 Fine Control of Buffer Updates
void colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
void depthMask(GLboolean flag);
void stencilMask(GLuint mask);
void stencilMaskSeparate(GLenum face, GLuint mask);
// 4.2.3 Clearing the Buffers
void clear(GLbitfield mask);
void clearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void clearDepth(GLclampf depth);
void clearStencil(GLint s);
// 4.3.1 Reading Pixels
void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, ArrayBufferView? pixels);
// 4.4.1 Binding and Managing Framebuffer Objects
void bindFramebuffer(GLenum target, WebGLFramebuffer? framebuffer);
void deleteFramebuffer(WebGLFramebuffer? framebuffer);
WebGLFramebuffer? createFramebuffer(); // genFramebuffers
// 4.4.3 Renderbuffer Objects
void bindRenderbuffer(GLenum target, WebGLRenderbuffer? renderbuffer);
void deleteRenderbuffer(WebGLRenderbuffer? renderbuffer);
WebGLRenderbuffer? createRenderbuffer(); // genRenderBuffers
void renderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
void framebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, WebGLRenderbuffer? renderbuffer);
void framebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, WebGLTexture? texture, GLint level);
// 4.4.5 Framebuffer Completeness
GLenum checkFramebufferStatus(GLenum target);
// 5.1 Flush and Finish
void finish();
void flush();
// 5.2 Hints
void hint(GLenum target, GLenum mode);
// 6.1.1 Simple Queries
any getParameter(GLenum pname); // GetBooleanv / GetIntegerv / GetFloatv
GLboolean isEnabled(GLenum cap);
// 6.1.3 Enumerated Queries
any getTexParameter(GLenum target, GLenum pname);
any getBufferParameter(GLenum target, GLenum pname);
any getFramebufferAttachmentParameter(GLenum target, GLenum attachment, GLenum pname);
any getRenderbufferParameter(GLenum target, GLenum pname);
// 6.1.4 Texture Queries
GLboolean isTexture(WebGLTexture? texture); // how's non-bound textures?
// 6.1.5 String Queries
// GetString => getParameter
// 6.1.6 Buffer Object Queries
GLboolean isBuffer(WebGLBuffer? buffer);
// 6.1.7 Framebuffer Object and Renderbuffer Queries
GLboolean isFramebuffer(WebGLFramebuffer? framebuffer);
GLboolean isRenderbuffer(WebGLRenderbuffer? renderbuffer);
// 6.1.8 Shader and Program Queries
GLboolean isShader(WebGLShader? shader);
any getShaderParameter(WebGLShader? shader, GLenum pname); // GetShaderiv
GLboolean isProgram(WebGLProgram? program);
any getProgramParameter(WebGLProgram? program, GLenum pname); // GetProgramiv
sequence<WebGLShader>? getAttachedShaders(WebGLProgram? program);
DOMString? getProgramInfoLog(WebGLProgram? program);
DOMString? getShaderInfoLog(WebGLShader? shader);
DOMString? getShaderSource(WebGLShader? shader);
WebGLShaderPrecisionFormat? getShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype);
any getVertexAttrib(GLuint index, GLenum pname);
GLsizeiptr getVertexAttribOffset(GLuint index, GLenum pname); // GetVertexAttribPointer
any getUniform(WebGLProgram? program, WebGLUniformLocation? location);
[Constructor(DOMString type, optional WebGLContextEventInit eventInit)]
interface WebGLContextEvent : Event {
readonly attribute DOMString statusMessage;
};
// EventInit is defined in the DOM4 specification.
dictionary WebGLContextEventInit : EventInit {
DOMString statusMessage;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment