type GLContext = WebGLRenderingContext | WebGL2RenderingContext; type GLResource = { dispose(): void; }; declare const glMap: (gl: GLContext) => { format: { rgba: 6408; rgb: 6407; alpha: 6406; luminance: 6409; luminanceAlpha: 6410; }; type: { uint8: 5121; float: 5126; }; wrap: { clamp: 33071; repeat: 10497; mirror: 33648; }; filter: { nearest: 9728; linear: 9729; }; attributeType: { float: 5126; byte: 5120; short: 5122; unsignedByte: 5121; unsignedShort: 5123; }; indexType: { uint8: 5121; uint16: 5123; uint32: 5125; }; blendFactor: { zero: 0; one: 1; srcColor: 768; oneMinusSrcColor: 769; dstColor: 774; oneMinusDstColor: 775; srcAlpha: 770; oneMinusSrcAlpha: 771; dstAlpha: 772; oneMinusDstAlpha: 773; constantColor: 32769; oneMinusConstantColor: 32770; constantAlpha: 32771; oneMinusConstantAlpha: 32772; srcAlphaSaturate: 776; }; blendEquation: { add: 32774; subtract: 32778; reverseSubtract: 32779; }; primitive: { points: 0; lines: 1; lineStrip: 3; lineLoop: 2; triangles: 4; triangleStrip: 5; triangleFan: 6; }; drawMode: { points: 0; lines: 1; lineStrip: 3; lineLoop: 2; triangleStrip: 5; triangleFan: 6; }; bufferTarget: { array: 34962; element: 34963; }; bufferUsage: { static: 35044; dynamic: 35048; stream: 35040; }; }; type GLMap = ReturnType; type GLBufferData = ArrayBufferView | ArrayLike | null; type GLBufferParams = { target: keyof GLMap["bufferTarget"]; usage: keyof GLMap["bufferUsage"]; data: GLBufferData; }; declare class GLBuffer implements GLResource { target: keyof GLMap["bufferTarget"]; usage: keyof GLMap["bufferUsage"]; readonly gl: GLContext; readonly handle: WebGLBuffer; constructor(gl: GLContext, params?: Partial); private normalizeData; use(fn: () => void): void; update(data: GLBufferData): void; dispose(): void; } type GLTextureSource = TexImageSource | ArrayBufferView | null; type GLTextureParams = { width: number; height: number; data: GLTextureSource; format: keyof GLMap["format"]; type: keyof GLMap["type"]; wrapS: keyof GLMap["wrap"]; wrapT: keyof GLMap["wrap"]; minFilter: keyof GLMap["filter"]; magFilter: keyof GLMap["filter"]; flipY: boolean; }; declare class GLTexture implements GLResource { readonly gl: GLContext; readonly handle: WebGLTexture; params: GLTextureParams; constructor(gl: GLContext, params?: Partial); get width(): number; get height(): number; bind(unit?: number): void; update(params?: Partial): void; resize(width: number, height: number): void; dispose(): void; } declare class GLFramebuffer implements GLResource { readonly gl: GLContext; readonly texture: GLTexture; readonly handle: WebGLFramebuffer; constructor(gl: GLContext, texture: GLTexture); use(fn: () => void): void; dispose(): void; } type BlendFactor = keyof GLMap["blendFactor"]; type BlendEquation = keyof GLMap["blendEquation"]; type GLBlendConfig = { enabled?: boolean; srcFactor?: BlendFactor | [BlendFactor, BlendFactor]; dstFactor?: BlendFactor | [BlendFactor, BlendFactor]; equation?: BlendEquation | [BlendEquation, BlendEquation]; }; type GLAttribute = { buffer: GLBuffer; size: number; type?: keyof GLMap["attributeType"]; normalized?: boolean; stride?: number; offset?: number; }; type GLAttributes = Record GLAttribute)>; type GLUniformValue = number | boolean | readonly number[] | Float32Array | Int32Array | GLTexture; type GLUniforms = Record GLUniformValue)>; type GLProgramDefinition = { vert?: string; frag?: string; primitive?: keyof GLMap["primitive"]; count?: number; offset?: number; indexType?: keyof GLMap["indexType"]; elements?: GLBuffer; attributes?: GLAttributes; uniforms?: GLUniforms; blend?: GLBlendConfig; }; declare class GLProgram implements GLResource { readonly gl: GLContext; private readonly handle; private blend; private elements?; private primitive; private count; private offset; private indexType?; private uniforms; private attributes; private attributeCache; static readonly DEFAULT_VERT = "\n precision mediump float;\n attribute vec2 position;\n varying vec2 uv;\n void main() {\n uv = position * 0.5 + 0.5;\n gl_Position = vec4(position, 0.0, 1.0);\n }\n "; static readonly DEFAULT_FRAG = "\n precision mediump float;\n varying vec2 uv;\n void main() {\n gl_FragColor = vec4(uv, 0.0, 1.0);\n }\n "; static createFSQuadBuffer(gl: GLContext): GLBuffer; constructor(gl: GLContext, definition?: GLProgramDefinition); private buildUniforms; private buildAttributes; private compileShader; private buildProgram; private writeUniformArray; private writeUniform; private applyUniforms; private writeAttribute; private applyAttributes; private applyBlend; private drawElements; private drawArrays; use(fn: () => void): void; draw(props?: Props): void; dispose(): void; } type GLRendererParams = { context?: GLContext; canvas?: HTMLCanvasElement | null; attributes?: WebGLContextAttributes; }; declare class GLRenderer { gl: GLContext; programs: WeakMap; private resources; constructor(params?: GLRendererParams); get canvas(): HTMLCanvasElement; resize(width: number, height: number): void; clear(color?: number[]): void; program(definition: GLProgramDefinition): GLProgram; texture(params?: Partial): GLTexture; framebuffer(texture?: GLTexture): GLFramebuffer; buffer(params?: Partial): GLBuffer; dispose(): void; } export { type GLAttribute, type GLAttributes, type GLBlendConfig, GLBuffer, type GLBufferData, type GLBufferParams, type GLContext, GLFramebuffer, type GLMap, GLProgram, type GLProgramDefinition, GLRenderer, type GLRendererParams, type GLResource, GLTexture, type GLTextureParams, type GLTextureSource, type GLUniformValue, type GLUniforms, glMap };