Skip to content

Core

RenderTarget ​

Defined in: packages/wtc-gl/src/core/RenderTarget.ts:54

Create a render target. A render target allows you to render a scene to a texture, instead of to screen. And can be used to either render a different view for composition to a scene, or to create advanced post processing effects.

Constructors ​

Constructor ​

ts
new RenderTarget(gl, options?): RenderTarget;

Defined in: packages/wtc-gl/src/core/RenderTarget.ts:114

Create a render target object.

Parameters ​

ParameterTypeDescription
glWTCGLRenderingContextThe WTCGL Rendering context
options?Partial<RenderTargetOptions>The size, attachments and texture settings; see RenderTargetOptions.

Returns ​

RenderTarget

Properties ​

PropertyTypeDefault valueDescription
bufferWebGLFramebufferundefinedThe WebGL frame buffer object to render to.
depthbooleanundefinedWhether to render a depth buffer.
depthBufferWebGLRenderbuffer | nullnullThe depth and/or stencil renderbuffer, used when the depth buffer isn't a texture or there's only a stencil buffer.
depthTextureTexture | nullnullThe depth (or depth-stencil) texture, if the depth buffer is a texture.
glWTCGLRenderingContextundefinedThe WTCGL rendering context.
heightnumberundefinedThe height of the target.
stencilbooleanundefinedWhether to render a stencil buffer.
targetnumberundefinedA GLEnum representing the binding point for the texture / buffer. Default gl.FRAMEBUFFER
texturesTexture[]undefinedThe texture array. If you supply only one colour, you can just output this as you normally would with gl_FragColor, otherwise you need to output one at a time with gl_FragData[x]
widthnumberundefinedThe width of the target.

Accessors ​

texture ​

Get Signature ​

ts
get texture(): Texture;

Defined in: packages/wtc-gl/src/core/RenderTarget.ts:321

The first colour texture, which is all most uses need.

Returns ​

Texture

Methods ​

remove() ​

ts
remove(): void;

Defined in: packages/wtc-gl/src/core/RenderTarget.ts:330

Delete the framebuffer along with its colour textures and depth buffer. A depth texture passed in through depthTexture is left alone. If the target is currently bound, the canvas is bound in its place.

Returns ​

void


resize() ​

ts
resize(width, height): void;

Defined in: packages/wtc-gl/src/core/RenderTarget.ts:274

Resize the target's textures and depth/stencil buffer in place, keeping the same framebuffer and texture objects (so uniforms that hold them stay valid). The contents are lost, and any data the textures were created with is dropped. A depth texture passed in through depthTexture is resized too, as the framebuffer needs every attachment to be one size.

Parameters ​

ParameterTypeDescription
widthnumberThe new width, in pixels.
heightnumberThe new height, in pixels.

Returns ​

void


restoreContext() ​

ts
restoreContext(): void;

Defined in: packages/wtc-gl/src/core/RenderTarget.ts:308

Recreate the framebuffer and its textures after the WebGL context has been restored. The contents are lost. Called by the renderer.

Returns ​

void