@lightningjs/renderer
Version:
Lightning 3 Renderer
70 lines (69 loc) • 2.57 kB
TypeScript
import type { Dimensions } from '../../../common/CommonTypes.js';
import type { TextureMemoryManager } from '../../TextureMemoryManager.js';
import type { WebGlContextWrapper } from '../../lib/WebGlContextWrapper.js';
import type { Texture } from '../../textures/Texture.js';
import { CoreContextTexture } from '../CoreContextTexture.js';
/**
* A wrapper around a WebGLTexture that handles loading the texture data
* from a Texture source and uploading it to the GPU as well as freeing
* the uploaded texture.
*
* @remarks
* When accessing the ctxTexture property, the texture will be loaded if
* it hasn't been already. ctxTexture will always return a valid WebGLTexture
* and trigger the loading/uploading of the texture's data if it hasn't been
* loaded yet.
*/
export declare class WebGlCoreCtxTexture extends CoreContextTexture {
protected glw: WebGlContextWrapper;
protected _nativeCtxTexture: WebGLTexture | null;
private _w;
private _h;
txCoordX1: number;
txCoordY1: number;
txCoordX2: number;
txCoordY2: number;
constructor(glw: WebGlContextWrapper, memManager: TextureMemoryManager, textureSource: Texture);
/**
* GL error check with direct state marking
* Uses cached error result to minimize function calls
*/
private checkGLError;
get ctxTexture(): WebGLTexture | null;
get w(): number;
get h(): number;
/**
* Load the texture data from the Texture source and upload it to the GPU
*
* @remarks
* This method is called automatically when accessing the ctxTexture property
* if the texture hasn't been loaded yet. But it can also be called manually
* to force the texture to be pre-loaded prior to accessing the ctxTexture
* property.
*/
load(): Promise<void>;
/**
* Called when the texture data needs to be loaded and uploaded to a texture
*/
onLoadRequest(): Promise<Dimensions>;
/**
* Free the WebGLTexture from the GPU
*
* @returns
*/
free(): void;
/**
* Release the WebGLTexture from the GPU without changing state
*/
release(): void;
/**
* Create native context texture asynchronously
*
* @remarks
* When this method resolves, the returned texture will be bound to the GL context state
* and fully ready for use. This ensures proper GPU resource allocation timing.
*
* @returns Promise that resolves to the native WebGL texture or null on failure
*/
protected createNativeCtxTexture(): WebGLTexture | null;
}