Class: RenderContext
Defined in: rendering/render-context.ts:12
The rendering context.
Constructors
Constructor
new RenderContext(
shaderCache,imageCache,canvas,clearStrategy?,preserveDrawingBuffer?):RenderContext
Defined in: rendering/render-context.ts:48
Constructs a new instance of the RenderContext class.
Parameters
shaderCache
The shader cache.
imageCache
The image cache.
canvas
HTMLCanvasElement
The canvas element.
clearStrategy?
CLEAR_STRATEGY_KEYS = CLEAR_STRATEGY.blank
The strategy for clearing the render context (default: CLEAR_STRATEGY.blank).
preserveDrawingBuffer?
boolean = false
Whether to retain the drawing buffer after presentation instead of letting the browser clear it, required for reading back the canvas's pixels (e.g. toDataURL, drawImage) after a frame has already been presented (default: false, since most consumers never read the canvas back and the retained buffer costs GPU memory bandwidth).
Returns
RenderContext
Properties
canvas
readonlycanvas:HTMLCanvasElement
Defined in: rendering/render-context.ts:27
The canvas element associated with the render context.
clearStrategy
clearStrategy:
CLEAR_STRATEGY_KEYS
Defined in: rendering/render-context.ts:14
The strategy for clearing the render context.
gl
readonlygl:WebGL2RenderingContext
Defined in: rendering/render-context.ts:30
The WebGL2 rendering context.
height
height:
number
Defined in: rendering/render-context.ts:36
imageCache
readonlyimageCache:ImageCache
Defined in: rendering/render-context.ts:24
The image cache containing loaded images.
instanceBuffer
instanceBuffer:
WebGLBuffer
Defined in: rendering/render-context.ts:32
shaderCache
readonlyshaderCache:ShaderCache
Defined in: rendering/render-context.ts:19
The shader store containing compiled shaders.
width
width:
number
Defined in: rendering/render-context.ts:34
Methods
bindRenderTarget()
bindRenderTarget(
target):void
Defined in: rendering/render-context.ts:101
Binds a render target as the current draw destination, or the default
framebuffer (the canvas) if null is passed. Updates the viewport to
match the bound target's dimensions.
Parameters
target
RenderTarget | null
The render target to bind, or null to bind the canvas.
Returns
void
clear()
clear(
color?):void
Defined in: rendering/render-context.ts:114
Clears the currently bound framebuffer's color buffer, according to clearStrategy.
Parameters
color?
Color = Color.transparent
Returns
void
getGlobalUniformValue()
getGlobalUniformValue(
name):UniformValue
Defined in: rendering/render-context.ts:127
Parameters
name
string
Returns
resize()
resize(
width,height):void
Defined in: rendering/render-context.ts:81
Resizes the render context canvas and updates the WebGL viewport.
Parameters
width
number
The new canvas width in pixels.
height
number
The new canvas height in pixels.
Returns
void
setGlobalUniformValue()
setGlobalUniformValue(
name,value):void
Defined in: rendering/render-context.ts:123
Parameters
name
string
value
Returns
void