TextureRenderer
The TextureRenderer class is the base class for rendering textures to screen or into frame buffers. It provides template methods that must be implemented by subclasses.
Constructor
Section titled “Constructor”constructor(renderer: Renderer, texture: Texture)Creates a new texture renderer. Throws if the texture is already owned by another texture renderer (checked via texture.renderer property).
Properties
Section titled “Properties”renderer
Section titled “renderer”The owning Renderer instance.
texture
Section titled “texture”The Texture being rendered by this renderer. Read-only exposure of the managed texture object.
Methods
Section titled “Methods”getApiObject(texture: Texture) : any
Section titled “getApiObject(texture: Texture) : any”Returns the underlying API object (texture identifier) for rendering. Must be overridden by subclasses:
// Example override in a GL-based subclass:override getApiObject(texture: Texture): WebGLTexture { return this.glTextures.get(texture.id);}destroy() : void
Section titled “destroy() : void”Must be overridden to clean up GL resources and remove texture.renderer ownership:
// Example override in a GL-based subclass:override destroy(): void { this.glTextures.delete(this.texture.id);}Design Notes
Section titled “Design Notes”This class uses the Template Method pattern. Subclasses implement:
getApiObject()— API-specific texture lookup for drawing callsdestroy()— cleanup of backend resources and ownership tracking
The base constructor enforces exclusive texture ownership by checking the hidden texture.renderer property, ensuring each texture is managed by exactly one renderer.