import { mat4 } from "gl-matrix"; import { RendererWithExposedMethods } from "./RendererWithExposedMethods"; export declare abstract class BaseRenderer implements RendererWithExposedMethods { protected mMMatrix: mat4; protected mVMatrix: mat4; protected mMVPMatrix: mat4; protected mProjMatrix: mat4; protected matOrtho: mat4; private m_boundTick; private m_gl; protected isWebGL2: boolean; protected viewportWidth: number; protected viewportHeight: number; protected canvas: HTMLCanvasElement | undefined; constructor(); /** Getter for current WebGL context. */ get gl(): WebGLRenderingContext | WebGL2RenderingContext; /** Logs last GL error to console */ logGLError(): void; /** * Binds 2D texture. * * @param textureUnit A texture unit to use * @param texture A texture to be used * @param uniform Shader's uniform ID */ setTexture2D(textureUnit: number, texture: WebGLTexture, uniform: WebGLUniformLocation): void; /** * Binds cubemap texture. * * @param textureUnit A texture unit to use * @param texture A texture to be used * @param uniform Shader's uniform ID */ setTextureCubemap(textureUnit: number, texture: WebGLTexture, uniform: WebGLUniformLocation): void; /** * Calculates FOV for matrix. * * @param matrix Output matrix * @param fovY Vertical FOV in degrees * @param aspect Aspect ratio of viewport * @param zNear Near clipping plane distance * @param zFar Far clipping plane distance */ setFOV(matrix: mat4, fovY: number, aspect: number, zNear: number, zFar: number): void; /** * Calculates MVP matrix. Saved in this.mMVPMatrix */ calculateMVPMatrix(tx: number, ty: number, tz: number, rx: number, ry: number, rz: number, sx: number, sy: number, sz: number): void; /** Called before WebGL initialization. */ abstract onBeforeInit(): void; /** Called right after WebGL initialization */ abstract onAfterInit(): void; /** Called on WebGL initialization error */ abstract onInitError(): void; /** Shaders initialization code goes here */ abstract initShaders(): void; /** Load WebGL data here */ abstract loadData(): void; /** Perform each frame's draw calls here. */ protected drawScene(): void; /** Update timers and aminate stuff here. */ abstract animate(): void; /** Called on each frame. */ private tick; /** * Initializes WebGL context. * * @param canvas Canvas to initialize WebGL. */ protected initGL(canvas: HTMLCanvasElement): WebGLRenderingContext; /** * Initializes WebGL 2 context * * @param canvas Canvas to initialize WebGL 2. */ protected initGL2(canvas: HTMLCanvasElement): WebGLRenderingContext | WebGL2RenderingContext; /** * Generates mipmasp for textures. * * @param textures Textures to generate mipmaps for. */ protected generateMipmaps(...textures: WebGLTexture[]): void; /** * Initializes WebGL and calls all callbacks. * * @param canvasID ID of canvas element to initialize WebGL. * @param requestWebGL2 Set to `true` to initialize WebGL 2 context. */ init(canvasID: string, requestWebGL2?: boolean): void; /** Adjusts viewport according to resizing of canvas. */ resizeCanvas(): void; /** * Logs GL error to console. * * @param operation Operation name. */ checkGlError(operation: string): void; /** @inheritdoc */ unbindBuffers(): void; /** @inheritdoc */ getMVPMatrix(): mat4; /** @inheritdoc */ getOrthoMatrix(): mat4; /** @inheritdoc */ getModelMatrix(): mat4; /** @inheritdoc */ getViewMatrix(): mat4; /** @inheritdoc */ getProjectionMatrix(): mat4; }