UNPKG

ts-game-engine

Version:

Simple WebGL game/render engine written in TypeScript

47 lines (46 loc) 1.78 kB
import { IDisposable, IUniformData } from "../Interfaces"; import { mat4, vec3, mat3, vec2 } from "gl-matrix"; import { Texture2D } from "../Textures/Texture2D"; import { Scene } from "../Scene"; import { TextureTypes } from "../Textures/Texture"; export declare const enum UniformTypes { Int1 = 0, Float1 = 1, Float1Vector = 2, Float2 = 3, Float2Vector = 4, Float3 = 5, Float3Vector = 6, Float4 = 7, Float4Vector = 8, Matrix3 = 9, Matrix4 = 10, Sampler2D = 11, SamplerCube = 12 } export declare class Shader implements IDisposable { private context; private pipelineState; private program; get Program(): WebGLProgram; private instancedAttributes; get InstancedAttributes(): Map<string, number>; private uniforms; get Uniforms(): Map<string, IUniformData>; private constructor(); Dispose(): void; DefineInstancedAttribute(name: string, location: number): void; DefineUniform(name: string, type: UniformTypes): void; SetInt1Uniform(uniformName: string, value: number): void; SetFloat2Uniform(uniformName: string, value: vec2): void; SetFloat3Uniform(uniformName: string, value: vec3): void; SetFloat4VectorUniform(uniformName: string, value: Float32Array): void; SetMatrix3Uniform(uniformName: string, value: mat3): void; SetMatrix4Uniform(uniformName: string, value: mat4): void; SetSamplerUniform(uniformName: string, textureUnit: number, texture: Texture2D, type: TextureTypes): void; private CreateShader; private CreateShaderProgram; private static readonly shaders; static Get(scene: Scene, name: string, vsSource: string, psSource: string): Shader; static DisposeAll(): void; }