import { GLCat } from './GLCat'; import { GLCatBuffer } from './GLCatBuffer'; import { GLCatShader } from './GLCatShader'; import { GLCatTexture } from './GLCatTexture'; declare type WebGL1 = WebGLRenderingContext; declare type WebGL2 = WebGL2RenderingContext; export declare type GLCatProgramUniformType = '1f' | '2f' | '3f' | '4f' | '1i' | '2i' | '3i' | '4i'; export declare type GLCatProgramUniformVectorType = '1fv' | '2fv' | '3fv' | '4fv' | '1iv' | '2iv' | '3iv' | '4iv'; export declare type GLCatProgramUniformMatrixVectorType = 'Matrix2fv' | 'Matrix3fv' | 'Matrix4fv'; export interface GLCatProgramLinkOptions { transformFeedbackVaryings?: string[]; /** * `gl.SEPARATE_ATTRIBS` by default */ transformFeedbackBufferMode?: number; } /** * It's a WebGLProgram, but has cache of variable locations. */ export declare class GLCatProgram { private __glCat; private __program; private __shaders; private __attribLocationCache; private __uniformLocationCache; private __uniformTextureUnitMap; private __uniformtextureUnitIndex; private __linked; /* * Its own program. */ readonly program: WebGLProgram; /* * Its own program. Shorter than [[GLCatProgram.program]]. */ readonly raw: WebGLProgram; /* * Its shaders. */ readonly shaders: GLCatShader[] | null; /* * Whether the last link operation was successful or not. */ readonly isLinked: boolean; /** * Create a new GLCatProgram instance. */ constructor(glCat: GLCat, program: WebGLProgram); /** * Dispose the program. */ dispose(alsoAttached?: boolean): void; /** * Attach shaders and link this program. */ link(shaders: GLCatShader[], options?: GLCatProgramLinkOptions): void; /** * Attach shaders and link this program. * It's gonna be asynchronous if you have the KHR_parallel_shader_compile extension support. */ linkAsync(shaders: GLCatShader[], options?: GLCatProgramLinkOptions): Promise; /** * Attach an attribute variable. * @param name Name of the attribute variable * @param buffer Vertex buffer. Can be null, to disable attribute array * @param size Number of components per vertex. Must be 1, 2, 3 or 4 */ attribute(name: string, buffer: GLCatBuffer | null, size?: number, divisor?: number, type?: number, stride?: number, offset?: number): void; /** * Attach an uniform variable. * See also: {@link GLCatProgram.uniformVector}, {@link GLCatProgram.uniformMatrixVector} */ uniform(name: string, type: GLCatProgramUniformType, ...value: number[]): void; /** * Attach a vector uniform variable. * See also: {@link GLCatProgram.uniform}, {@link GLCatProgram.uniformMatrixVector} */ uniformVector(name: string, type: GLCatProgramUniformVectorType, value: Float32List | Int32List): void; /** * Attach a matrix vector uniform variable. * See also: {@link GLCatProgram.uniform}, {@link GLCatProgram.uniformVector} */ uniformMatrixVector(name: string, type: GLCatProgramUniformMatrixVectorType, value: Float32List | Int32List, transpose?: boolean): void; /** * Attach an uniform texture / multiple textures. * @param name Name of the uniform texture * @param texture Texture object */ uniformTexture(name: string, ...textures: GLCatTexture[]): void; /** * Retrieve attribute location. */ getAttribLocation(name: string): number; /** * Retrieve uniform location. */ getUniformLocation(name: string): WebGLUniformLocation | null; /** * Retrieve or create a texture unit that corresponds to given name. */ getUniformTextureUnit(name: string, textureUnitsUse?: number): number; } export {};