import { GLCatProgram, GLCatProgramLinkOptions } from './GLCatProgram'; import { GLCatBuffer } from './GLCatBuffer'; import { GLCatFramebuffer } from './GLCatFramebuffer'; import { GLCatRenderbuffer } from './GLCatRenderbuffer'; import { GLCatShader } from './GLCatShader'; import { GLCatTexture } from './GLCatTexture'; import { GLCatTextureCubemap } from './GLCatTextureCubemap'; import { GLCatTransformFeedback } from './GLCatTransformFeedback'; import { GLCatVertexArray } from './GLCatVertexArray'; declare type WebGL1 = WebGLRenderingContext; declare type WebGL2 = WebGL2RenderingContext; export declare type WebGLExtension = any; export declare type GLCatVertexArrayRawType = TContext extends WebGL2 ? WebGLVertexArrayObject : WebGLVertexArrayObjectOES; /** * WebGL wrapper with plenty of hackability. */ export declare class GLCat { static throwIfNull(v: T | null): T; preferredMultisampleSamples: number; preferredDepthFormat: GLenum; private __gl; private __bindHelperVertexBuffer; private __bindHelperIndexBuffer; private __bindHelperTransformFeedback; private __bindHelperVertexArray; private __bindHelperTexture2D; private __bindHelperTextureCubeMap; private __bindHelperRenderbuffer; private __bindHelperFramebuffer; private __bindHelperProgram; private __bindHelperDrawBuffers; private __extensionCache; private __dummyTextureCache?; /** * Its own rendering context. */ get renderingContext(): TContext; /** * Its own rendering context. Shorter than [[GLCat.renderingContext]] */ get gl(): TContext; /** * Create a new GLCat instance. * Rendering context is required. */ constructor(gl: TContext); /** * A dummy texture, 100% organic pure #FF00FF texture. */ get dummyTexture(): GLCatTexture; /** * Retrieve an extension. * If they is your precious one and you cannot live without him, turn on `throwIfNotFound`. */ getExtension(name: 'OES_texture_half_float', throwIfNotFound?: false): OES_texture_half_float | null; getExtension(name: 'OES_texture_half_float', throwIfNotFound: true): OES_texture_half_float; getExtension(name: 'OES_texture_half_float_linear', throwIfNotFound?: false): OES_texture_half_float_linear | null; getExtension(name: 'OES_texture_half_float_linear', throwIfNotFound: true): OES_texture_half_float_linear; getExtension(name: 'OES_texture_float', throwIfNotFound?: false): OES_texture_float | null; getExtension(name: 'OES_texture_float', throwIfNotFound: true): OES_texture_float; getExtension(name: 'OES_texture_float_linear', throwIfNotFound?: false): OES_texture_float_linear | null; getExtension(name: 'OES_texture_float_linear', throwIfNotFound: true): OES_texture_float_linear; getExtension(name: 'ANGLE_instanced_arrays', throwIfNotFound?: false): ANGLE_instanced_arrays | null; getExtension(name: 'ANGLE_instanced_arrays', throwIfNotFound: true): ANGLE_instanced_arrays; getExtension(name: 'OES_vertex_array_object', throwIfNotFound?: false): OES_vertex_array_object | null; getExtension(name: 'OES_vertex_array_object', throwIfNotFound: true): OES_vertex_array_object; getExtension(name: 'WEBGL_draw_buffers', throwIfNotFound?: false): WEBGL_draw_buffers | null; getExtension(name: 'WEBGL_draw_buffers', throwIfNotFound: true): WEBGL_draw_buffers; getExtension(name: string, throwIfNotFound?: boolean): WebGLExtension | null; /** * Retrieve extensions. * If they are your precious ones and you cannot live without them, turn on `throwIfNotFound`. */ getExtensions(names: string[], throwIfNotFound?: boolean): Array; /** * Create a new shader object. */ createShader(type: number): GLCatShader; /** * Create a new GLCat program object. */ createProgram(): GLCatProgram; /** * Create a new GLCat program object, in lazier way. */ lazyProgram(vert: string, frag: string, options?: GLCatProgramLinkOptions): GLCatProgram; /** * Create a new GLCat program object, in lazier way. * It's gonna be asynchronous if you have the KHR_parallel_shader_compile extension support. */ lazyProgramAsync(vert: string, frag: string, options?: GLCatProgramLinkOptions): Promise>; /** * Specify a program to use. * If callback is provided, it will execute the callback immediately, and undo the usage after the callback. */ useProgram(program: GLCatProgram | null, callback?: (program: GLCatProgram | null) => T): T; /** * Create a new vertex buffer. */ createBuffer(): GLCatBuffer; /** * Bind a vertex buffer. * If callback is provided, it will execute the callback immediately, and undo the bind after the callback. */ bindVertexBuffer(buffer: GLCatBuffer | null, callback?: (buffer: GLCatBuffer | null) => T): T; /** * Bind an index buffer. * If callback is provided, it will execute the callback immediately, and undo the bind after the callback. */ bindIndexBuffer(buffer: GLCatBuffer | null, callback?: (buffer: GLCatBuffer | null) => T): T; /** * Create a new transform feedback. */ createTransformFeedback(): GLCatTransformFeedback; /** * Bind a transform feedback. * If callback is provided, it will execute the callback immediately, and undo the bind after the callback. */ bindTransformFeedback(transformFeedback: GLCatTransformFeedback | null, callback?: (transformFeedback: GLCatTransformFeedback | null) => T): T; /** * Create a new vertex array. */ createVertexArray(): GLCatVertexArray; /** * Wrapper of `gl.bindVertexArray`. * * {@link rawBindVertexArray} is better. */ rawBindVertexArray(array: GLCatVertexArrayRawType | null): void; /** * {@link rawBindVertexArray} but better. * * Bind a vertex array. * If callback is provided, it will execute the callback immediately, and undo the bind after the callback. */ bindVertexArray(vertexArray: GLCatVertexArray | null, callback?: (vertexArray: GLCatVertexArray | null) => T): T; /** * Create a new texture. */ createTexture(): GLCatTexture; /** * Create a new cubemap texture. */ createTextureCubemap(): GLCatTextureCubemap; /** * Bind a 2D texture. * If callback is provided, it will execute the callback immediately, and undo the bind after the callback. */ bindTexture2D(texture: GLCatTexture | null, callback?: (texture: GLCatTexture | null) => T): T; /** * Bind a cubemap texture. * If callback is provided, it will execute the callback immediately, and undo the bind after the callback. */ bindTextureCubeMap(texture: GLCatTexture | null, callback?: (texture: GLCatTexture | null) => T): T; /** * Create a new renderbuffer. */ createRenderbuffer(): GLCatRenderbuffer; /** * Bind a renderbuffer. * If callback is provided, it will execute the callback immediately, and undo the bind after the callback. */ bindRenderbuffer(renderbuffer: GLCatRenderbuffer | null, callback?: (renderbuffer: GLCatRenderbuffer | null) => T): T; /** * Create a new framebuffer. */ createFramebuffer(): GLCatFramebuffer; /** * Bind a framebuffer. * If callback is provided, it will execute the callback immediately, and undo the bind after the callback. */ bindFramebuffer(framebuffer: GLCatFramebuffer | null, callback?: (framebuffer: GLCatFramebuffer | null) => T): T; /** * Create a new framebufer, in lazier way. */ lazyFramebuffer(width: number, height: number, { isFloat, depthFormat }?: { isFloat?: boolean | undefined; depthFormat?: number | undefined; }): GLCatFramebuffer; /** * Create a new cubemap framebufer, in lazier way. */ lazyCubemapFramebuffer(width: number, height: number, { isFloat, depthFormat }?: { isFloat?: boolean | undefined; depthFormat?: number | undefined; }): { framebuffer: GLCatFramebuffer; texture: GLCatTextureCubemap; }; /** * Create a new multisample framebuffer, in lazier way. */ lazyMultisampleFramebuffer(width: number, height: number, { samples, isFloat, depthFormat, fallbackWebGL1 }?: { samples?: number | undefined; isFloat?: boolean | undefined; depthFormat?: number | undefined; fallbackWebGL1?: boolean | undefined; }): GLCatFramebuffer; /** * Create a new draw buffers, in lazier way. * If you can't grab `WEBGL_draw_buffers` extension, you'll die instantly at this point. */ lazyDrawbuffers(width: number, height: number, numBuffers: number, { isFloat, depthFormat }?: { isFloat?: boolean | undefined; depthFormat?: number | undefined; }): GLCatFramebuffer; /** * Wrapper of `gl.drawBuffers`. * * {@link drawBuffers} is better. */ rawDrawBuffers(buffers: GLenum[]): void; /** * {@link rawDrawBuffers} but better. * * Call this before you're gonna use draw buffers. * If you can't grab `WEBGL_draw_buffers` extension, you'll die instantly at this point. * If callback is provided, it will execute the callback immediately, and undo the draw buffers after the callback. */ drawBuffers(buffersOrNumBuffers?: GLenum[] | number, callback?: (buffers: GLenum[]) => T): T; /** * a wrapper of drawElementsInstanced. */ drawArraysInstanced(mode: GLenum, first: GLint, count: GLsizei, primcount: GLsizei): void; /** * a wrapper of drawElementsInstanced. */ drawElementsInstanced(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr, instanceCount: GLsizei): void; /** * Clear the current framebuffer. */ clear(red?: number, green?: number, blue?: number, alpha?: number, depth?: number): void; /** * Basically just a `gl.blitFramebuffer`. */ blitFramebuffer(src: GLCatFramebuffer | null, dst: GLCatFramebuffer | null, { srcViewport, dstViewport, mask, filter }?: { srcViewport?: number[] | undefined; dstViewport?: number[] | undefined; mask?: number | undefined; filter?: number | undefined; }): void; } export {};