gl2d
Version:
2D graphics package for WebGL
67 lines (66 loc) • 3.11 kB
TypeScript
export declare type ArraySize = number | ArrayBuffer | ArrayBufferView;
export declare type ElementArraySize = number | ArrayBuffer | Uint8Array | Uint16Array;
/**
* Maps the name of a uniform or attribute to it's minified renaming.
*/
export interface Renaming {
[key: string]: string;
}
/**
* Maps the name of a uniform to its location in a WebGL program.
*/
export interface UniformLocations {
[key: string]: WebGLUniformLocation;
}
/**
* Maps the name of an attribute to its location in a WebGL program.
*/
export interface AttribLocations {
[key: string]: number;
}
/**
* Creates an array buffer with the specified size.
* @param gl the WebGL context.
* @param size the size of the array buffer, or the initial data for the buffer.
* @param usage one of gl.STATIC_DRAW (often used, seldom changed), gl.DYNAMIC_DRAW (often used, often changed), or gl.STREAM_DRAW (seldom used).
*/
export declare function createArrayBuffer(gl: WebGLRenderingContext, size: ArraySize, usage?: number): WebGLBuffer;
/**
* Creates an element buffer with the specified size.
* @param gl the WebGL context.
* @param size the size of the element buffer, or the initial data for the buffer.
* @param usage one of gl.STATIC_DRAW (often used, seldom changed), gl.DYNAMIC_DRAW (often used, often changed), or gl.STREAM_DRAW (seldom used).
*/
export declare function createElementBuffer(gl: WebGLRenderingContext, size: ElementArraySize, usage?: number): WebGLBuffer;
/**
* Creates a program from 2 shaders.
* @param gl the WebGL context.
* @param vertexShaderSource string containing code for the vertex shader.
* @param fragmentShaderSource string containing code for the fragment shader.
* @returns the program.
*/
export declare function createProgramFromSources(gl: WebGLRenderingContext, vertexShaderSource: string, fragmentShaderSource: string): WebGLProgram;
/**
* Creates a program from 2 shaders.
* @param gl rhe WebGL context.
* @param vertexShader a compiled vertex shader.
* @param fragmentShader a compiled fragment shader.
* @returns the program.
*/
export declare function createProgramFromShaders(gl: WebGLRenderingContext, vertexShader: WebGLShader, fragmentShader: WebGLShader): WebGLProgram;
/**
* Creates and compiles a shader.
* @param gl the WebGL Context.
* @param shaderSource the GLSL source code for the shader.
* @param shaderType the type of shader, VERTEX_SHADER or FRAGMENT_SHADER.
* @returns the shader.
*/
export declare function compileShader(gl: WebGLRenderingContext, shaderSource: string, shaderType: number): WebGLShader;
/**
* Gets the location of each of the uniforms associated with the specified program.
*/
export declare function getUniformLocations(gl: WebGLRenderingContext, program: WebGLProgram, renamed?: Renaming): UniformLocations;
/**
* Gets the location of each of the attributes associated with the specified program.
*/
export declare function getAttributeLocations(gl: WebGLRenderingContext, program: WebGLProgram, renamed?: Renaming): AttribLocations;