UNPKG

webgl-dsl

Version:

Thin functional WebGL wrapper with strong typed GLSL DSL

101 lines (100 loc) 3.91 kB
import { Gl } from './gl'; import { BlendEquation, BlendFunction, AttributeDataType, DepthFunction, FaceCulling } from './enums'; import { AttributeLocation, Program } from './program'; import { ElementsBuffer } from './elements-buffer'; import { ArrayBuffer } from './array-buffer'; import { RenderBuffer } from './render-buffer'; import { FrameBuffer } from './frame-buffer'; import { Texture } from './texture'; export interface AttributePointer { buffer: ArrayBuffer; type: AttributeDataType; /** * Stride in bytes. */ stride: number; /** * Offset in bytes. */ offset: number; divisor: number; } export interface SettingsCache { blend: boolean; viewport: [number, number, number, number]; scissorTest: boolean; scissorBox: [number, number, number, number]; depthTest: boolean; depthFunction: DepthFunction; clearDepth: number; lineWidth: number; blendEquation: [BlendEquation, BlendEquation]; blendFunction: [BlendFunction, BlendFunction, BlendFunction, BlendFunction]; clearColor: [number, number, number, number]; activeTexture: number; textures: Map<number, Texture>; arrayBuffer: ArrayBuffer | null; elementsBuffer: ElementsBuffer | null; program: Program | null; attributes: Map<AttributeLocation, AttributePointer>; renderBuffer: RenderBuffer | null; frameBuffer: FrameBuffer | null; cullFace: boolean; cullFaceMode: FaceCulling; } export declare namespace SettingsCache { function initial(): SettingsCache; } export declare class Settings { readonly gl: Gl; private readonly cache; readonly apply: <T>(callback: () => T) => T; constructor(gl: Gl, cache: SettingsCache, apply?: <T>(callback: () => T) => T); private static cached; then(settings: Settings): Settings; private static blend; blend(value: boolean): Settings; private static cullFace; cullFace(value: boolean): Settings; private static cullFaceMode; cullFaceMode(value: FaceCulling): Settings; private static viewport; viewport(x: number, y: number, width: number, height: number): Settings; private static scissorTest; scissorTest(value: boolean): Settings; private static scissorBox; scissorBox(x: number, y: number, width: number, height: number): Settings; private static depthTest; depthTest(value: boolean): Settings; private static clearDepth; clearDepth(value: number): Settings; private static lineWidth; lineWidth(value: number): Settings; private static blendEquation; blendEquation(rgb: BlendEquation, alpha?: BlendEquation): Settings; private static blendFunction; blendFunction(srcRgb: BlendFunction, dstRgb: BlendFunction, srcAlpha?: BlendFunction, dstAlpha?: BlendFunction): Settings; private static depthFunction; depthFunction(value: DepthFunction): Settings; private static clearColor; clearColor(r: number, g: number, b: number, a: number): Settings; private static activeTexture; activeTexture(value: number): Settings; private static texture; texture(i: number, texture: Texture | null): Settings; textures(textures: (Texture | null)[]): Settings; private static arrayBuffer; arrayBuffer(value: ArrayBuffer | null): Settings; private static elementsBuffer; elementsBuffer(value: ElementsBuffer | null): Settings; private static program; program(value: Program | null): Settings; private static renderBuffer; renderBuffer(value: RenderBuffer | null): Settings; private static frameBuffer; frameBuffer(value: FrameBuffer | null): Settings; renderTarget(texture: Texture): Settings; private writeAttributePointer; attribute(location: AttributeLocation, pointer: AttributePointer | null): Settings; attributes(attributes: Map<AttributeLocation, AttributePointer>): Settings; }