@thi.ng/webgl
Version:
WebGL & GLSL abstraction layer
34 lines • 1.92 kB
TypeScript
import type { IObjectOf } from "@thi.ng/api";
import { GLSLVersion } from "@thi.ng/shader-ast-glsl/api";
import type { ModelAttributeSpecs, ModelSpec } from "./api/model.js";
import { type DefShaderOpts, type IShader, type ShaderAttrib, type ShaderSpec, type ShaderState, type ShaderType, type ShaderUniforms, type UniformValues } from "./api/shader.js";
export declare class Shader implements IShader {
gl: WebGLRenderingContext;
program: WebGLProgram;
attribs: IObjectOf<ShaderAttrib>;
uniforms: ShaderUniforms;
state: Partial<ShaderState>;
protected warnAttrib: (x: string) => void;
protected warnUni: (x: string) => void;
constructor(gl: WebGLRenderingContext, program: WebGLProgram, attribs: IObjectOf<ShaderAttrib>, uniforms: ShaderUniforms, state?: Partial<ShaderState>);
/**
* Returns a shallow copy of this shader with its state config merged with
* given options (priority). Useful for re-using a shader, but applying
* different settings.
*
* @param state
*/
withState(state: Partial<ShaderState>): Shader;
bind(spec: ModelSpec): boolean;
unbind(): boolean;
release(): boolean;
bindAttribs(specAttribs: ModelAttributeSpecs): void;
bindUniforms(specUnis?: UniformValues): void;
prepareState(state?: Partial<ShaderState>): void;
protected setState(id: number, val: GLenum | boolean): void;
}
export declare const defShader: (gl: WebGLRenderingContext, spec: ShaderSpec, opts?: Partial<DefShaderOpts>) => Shader;
export declare const shaderSourceFromAST: (spec: ShaderSpec, type: ShaderType, version: GLSLVersion, opts?: Partial<DefShaderOpts>) => string;
export declare const prepareShaderSource: (spec: ShaderSpec, type: ShaderType, version: GLSLVersion) => string;
export declare const compileShader: (gl: WebGLRenderingContext, type: GLenum, src: string) => WebGLShader;
//# sourceMappingURL=shader.d.ts.map