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
new RenderTarget(gl, options?): RenderTarget;Defined in: packages/wtc-gl/src/core/RenderTarget.ts:114
Create a render target object.
Parameters
| Parameter | Type | Description |
|---|---|---|
gl | WTCGLRenderingContext | The WTCGL Rendering context |
options? | Partial<RenderTargetOptions> | The size, attachments and texture settings; see RenderTargetOptions. |
Returns
RenderTarget
Properties
| Property | Type | Default value | Description |
|---|---|---|---|
buffer | WebGLFramebuffer | undefined | The WebGL frame buffer object to render to. |
depth | boolean | undefined | Whether to render a depth buffer. |
depthBuffer | WebGLRenderbuffer | null | null | The depth and/or stencil renderbuffer, used when the depth buffer isn't a texture or there's only a stencil buffer. |
depthTexture | Texture | null | null | The depth (or depth-stencil) texture, if the depth buffer is a texture. |
gl | WTCGLRenderingContext | undefined | The WTCGL rendering context. |
height | number | undefined | The height of the target. |
stencil | boolean | undefined | Whether to render a stencil buffer. |
target | number | undefined | A GLEnum representing the binding point for the texture / buffer. Default gl.FRAMEBUFFER |
textures | Texture[] | undefined | The 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] |
width | number | undefined | The width of the target. |
Accessors
texture
Get Signature
get texture(): Texture;Defined in: packages/wtc-gl/src/core/RenderTarget.ts:321
The first colour texture, which is all most uses need.
Returns
Methods
remove()
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()
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
| Parameter | Type | Description |
|---|---|---|
width | number | The new width, in pixels. |
height | number | The new height, in pixels. |
Returns
void
restoreContext()
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