UNPKG

gl2d

Version:

2D graphics package for WebGL

45 lines (44 loc) 1.39 kB
import { Camera } from './camera'; import { _Program } from './program'; /** * Helper class for rendering graphics with WebGL. */ export declare abstract class Renderer { /** * The WebGL rendering context used by this renderer. */ gl: WebGLRenderingContext; /** * The projection being applied by this renderer. */ camera: Camera; /** * The location of the currently bound program. */ private currentProgram; /** * Creates a new rendering object. * @param the WebGL rendering context to use. * @param camera the camera that should be used. */ constructor(gl: WebGLRenderingContext, camera: Camera); /** * Called when the surface hosting this renderer is first created. */ abstract onSurfaceCreated(): void; /** * Called whenever the canvas size changes. * @param width the new width of the canvas. * @param height the new height of the canvas. */ onSurfaceChanged(width: number, height: number): void; /** * Called whenever the canvas needs to be re-rendered. */ abstract onDrawFrame(): void; /** * Binds the specified program to the WebGL rendering context, if not already bound. * @param program the program to bind. */ attachProgram<P extends _Program>(program: P): void; }