UNPKG

@knopkem/little-game-engine-ts

Version:

LittleGameEngineTS - Tiny and Fast HTML5 Game Engine typescript port of LittleJS

69 lines (68 loc) 3.94 kB
/** * LittleJS WebGL Interface * <br> - All webgl used by the engine is wrapped up here * <br> - Can be disabled with glEnable to revert to 2D canvas rendering * <br> - Batches sprite rendering on GPU for incredibly fast performance * <br> - Sprite transform math is done in the shader where possible * <br> - For normal stuff you won't need to call any functions in this file * <br> - For advanced stuff there are helper functions to create shaders, textures, etc * @namespace WebGL */ /** The WebGL canvas which appears above the main canvas and below the overlay canvas * @type {HTMLCanvasElement} * @memberof WebGL */ export declare let glCanvas: any; /** 2d context for glCanvas * @type {WebGLRenderingContext} * @memberof WebGL */ export declare let glContext: any; /** Main tile sheet texture automatically loaded by engine * @type {WebGLTexture} * @memberof WebGL */ export declare let glTileTexture: any; export declare let glActiveTexture: any, glShader: any, glPositionData: any, glColorData: any, glBatchCount: number, glDirty: number, glAdditive: number; export declare function glInit(): void; /** Set the WebGl blend mode, normally you should call setBlendMode instead * @param {Boolean} [additive=0] * @memberof WebGL */ export declare function glSetBlendMode(additive?: number): void; /** Set the WebGl texture, not normally necessary unless multiple tile sheets are used * <br> - This may also flush the gl buffer resulting in more draw calls and worse performance * @param {WebGLTexture} [texture=glTileTexture] * @memberof WebGL */ export declare function glSetTexture(texture?: any): void; /** Compile WebGL shader of the given type, will throw errors if in debug mode * @param {String} source * @param type * @return {WebGLShader} * @memberof WebGL */ export declare function glCompileShader(source: any, type: any): any; /** Create WebGL program with given shaders * @param {WebGLShader} vsSource * @param {WebGLShader} fsSource * @return {WebGLProgram} * @memberof WebGL */ export declare function glCreateProgram(vsSource: any, fsSource: any): any; /** Create WebGL buffer * @param bufferType * @param size * @param usage * @return {WebGLBuffer} * @memberof WebGL */ export declare function glCreateBuffer(bufferType: any, size: any, usage: any): any; /** Create WebGL texture from an image * @param {Image} image * @return {WebGLTexture} * @memberof WebGL */ export declare function glCreateTexture(image: any): any; export declare function glPreRender(width: any, height: any): void; /** Draw all sprites and clear out the buffer, called automatically by the system whenever necessary * @memberof WebGL */ export declare function glFlush(): void; /** Draw any sprites still in the buffer, copy to main canvas and clear * @param {CanvasRenderingContext2D} context * @param {Boolean} [forceDraw=0] * @memberof WebGL */ export declare function glCopyToContext(context: any, forceDraw?: any): void; export declare function glDraw(x: any, y: any, sizeX: any, sizeY: any, angle?: number, uv0X?: number, uv0Y?: number, uv1X?: number, uv1Y?: number, rgba?: number, rgbaAdditive?: number): void; export declare const gl_ONE = 1, gl_TRIANGLES = 4, gl_SRC_ALPHA = 770, gl_ONE_MINUS_SRC_ALPHA = 771, gl_BLEND = 3042, gl_TEXTURE_2D = 3553, gl_UNSIGNED_BYTE = 5121, gl_FLOAT = 5126, gl_RGBA = 6408, gl_NEAREST = 9728, gl_LINEAR = 9729, gl_TEXTURE_MAG_FILTER = 10240, gl_TEXTURE_MIN_FILTER = 10241, gl_TEXTURE_WRAP_S = 10242, gl_TEXTURE_WRAP_T = 10243, gl_COLOR_BUFFER_BIT = 16384, gl_CLAMP_TO_EDGE = 33071, gl_ARRAY_BUFFER = 34962, gl_DYNAMIC_DRAW = 35048, gl_FRAGMENT_SHADER = 35632, gl_VERTEX_SHADER = 35633, gl_COMPILE_STATUS = 35713, gl_LINK_STATUS = 35714, gl_VERTICES_PER_QUAD = 6, gl_INDICIES_PER_VERT = 9, gl_MAX_BATCH: number, gl_VERTEX_BYTE_STRIDE: number;