Class: Renderer
renderer/renderer.Renderer
Renders single instances of shapes at a time.
Hierarchy
Rendererโณ
BatchRendererโณ
FluidRenderer
Constructors
constructor
โข new Renderer()
Properties
camera
โช Static Private camera: Camera
Defined in
src/renderer/renderer.ts:38
circleProgram
โช Static circleProgram: WebGLProgram
Defined in
src/renderer/renderer.ts:58
circleProgramInfo
โช Static circleProgramInfo: ShaderProgramInfo
Defined in
src/renderer/renderer.ts:59
gl
โช Static Private gl: WebGL2RenderingContext
Defined in
src/renderer/renderer.ts:35
indexBuffer
โช Static indexBuffer: WebGLBuffer
Defined in
src/renderer/renderer.ts:51
metaballProgram
โช Static metaballProgram: WebGLProgram
Defined in
src/renderer/renderer.ts:64
metaballProgramInfo
โช Static metaballProgramInfo: ShaderProgramInfo
Defined in
src/renderer/renderer.ts:65
mode
โช Static Private mode: "TRIANGLES" | "LINES" | "POINTS" = "TRIANGLES"
Defined in
src/renderer/renderer.ts:37
opacityBuffer
โช Static opacityBuffer: WebGLBuffer
Defined in
src/renderer/renderer.ts:52
positionBuffer
โช Static positionBuffer: WebGLBuffer
Defined in
src/renderer/renderer.ts:48
queue
โช Static Protected queue: ZMap<RenderQueueItem[]> = {}
Defined in
src/renderer/renderer.ts:45
rectProgram
โช Static rectProgram: WebGLProgram
Defined in
src/renderer/renderer.ts:55
rectProgramInfo
โช Static rectProgramInfo: ShaderProgramInfo
Defined in
src/renderer/renderer.ts:56
resolutionScale
โช Static Private resolutionScale: number = 1
Defined in
src/renderer/renderer.ts:36
scale
โช Static Protected scale: vec2
The scale applied to shape vertices to obtain their clip space vertices.
Defined in
src/renderer/renderer.ts:43
texBuffer
โช Static texBuffer: WebGLBuffer
Defined in
src/renderer/renderer.ts:49
triangleProgram
โช Static triangleProgram: WebGLProgram
Defined in
src/renderer/renderer.ts:61
triangleProgramInfo
โช Static triangleProgramInfo: ShaderProgramInfo
Defined in
src/renderer/renderer.ts:62
uvBuffer
โช Static uvBuffer: WebGLBuffer
Defined in
src/renderer/renderer.ts:50
Methods
clear
โธ Static clear(clearColor): void
Parameters
| Name | Type |
|---|---|
clearColor | Color |
Returns
void
Defined in
src/renderer/renderer.ts:203
flush
โธ Static flush(z): void
Renders all items currently in the render queue and clears the queue.
Should be called at the end of each frame.
If there is no camera specified in Renderer then nothing will be rendered.
Parameters
| Name | Type |
|---|---|
z | number |
Returns
void
Defined in
src/renderer/renderer.ts:214
getCamera
โธ Static getCamera(): Camera
Gets the camera that is currently being used for rendering.
Returns
The camera that is currently being used for rendering
Defined in
src/renderer/renderer.ts:395
getGL
โธ Static getGL(): WebGL2RenderingContext
Gets the renderer's webgl context.
Returns
WebGL2RenderingContext
The renderer's webgl context
Defined in
src/renderer/renderer.ts:330
getMode
โธ Static getMode(): "TRIANGLES" | "LINES" | "POINTS"
Gets the current webgl rendering mode being used by the renderer.
Returns
"TRIANGLES" | "LINES" | "POINTS"
The rendering mode
Defined in
src/renderer/renderer.ts:377
getQueue
โธ Static getQueue(): ZMap<RenderQueueItem[]>
Gets the render queue.
Returns
ZMap<RenderQueueItem[]>
the render queue
Defined in
src/renderer/renderer.ts:422
getQueueMax
โธ Static getQueueMax(): number
Gets the maximum zIndex used by the queue.
Returns
number
The max zIndex of the queue
Defined in
src/renderer/renderer.ts:431
getQueueMin
โธ Static getQueueMin(): number
Gets the minimum zIndex used by the queue.
Returns
number
The min zIndex of the queue
Defined in
src/renderer/renderer.ts:440
getResolutionScale
โธ Static getResolutionScale(): number
Gets the renderer's current resolution scale.
Returns
number
The renderer's current resolution scale
Defined in
src/renderer/renderer.ts:353
getScale
โธ Static getScale(): vec2
Gets the scale that is applied to vertices to obtain the vertices in clip space.
Returns
vec2
The scaling vector
Defined in
src/renderer/renderer.ts:413
init
โธ Static init(canvas, opts?): void
Sets up the renderer to be used for rendering.
Creates the webgl2 rendering context for the canvas and clears the webgl buffer.
throws When browser does not support webgl 2.0
Parameters
| Name | Type | Description |
|---|---|---|
canvas | HTMLCanvasElement | The canvas to grab webgl context from |
opts? | WebGLContextAttributes | {@link WebGLContextAttributes} to pass to the getContext call |
Returns
void
Defined in
src/renderer/renderer.ts:77
initShaders
โธ Static Private initShaders(gl): void
Parameters
| Name | Type |
|---|---|
gl | WebGL2RenderingContext |
Returns
void
Defined in
src/renderer/renderer.ts:114
queueShape
โธ Static queueShape(shape, position?, rotation?, zIndex?): void
Adds a shape to the render queue.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
shape | Shape | undefined | The shape to queue |
position | vec2 | undefined | The x and y position to render the rectangle at |
rotation | number | 0 | The rotation to apply to the shape |
zIndex | number | 0 | The z position of the rendered rectangle |
Returns
void
Defined in
src/renderer/renderer.ts:238
renderQueueItem
โธ Static Private renderQueueItem(item, zIndex): void
Renders a shape from a {@link RenderQueueItem} object.
Parameters
| Name | Type | Description |
|---|---|---|
item | RenderQueueItem | The {@link RenderQueueItem} to render |
zIndex | number | The z index to render the shape at |
Returns
void
Defined in
src/renderer/renderer.ts:258
resizeToCanvas
โธ Static resizeToCanvas(): void
Resizes the width and height of the canvas attached to gl to the canvas' clientWidth and clientHeight multiplied by the resolutionScale or 1.
Returns
void
Defined in
src/renderer/renderer.ts:191
setMode
โธ Static setMode(mode): void
Sets the mode the renderer will use for drawing.
throws When the provided mode is not TRIANGLES, LINES or POINTS
Parameters
| Name | Type | Description |
|---|---|---|
mode | "TRIANGLES" | "LINES" | "POINTS" | The mode to use |
Returns
void
Defined in
src/renderer/renderer.ts:364
setQueueMax
โธ Static setQueueMax(max): void
Sets the maximum zIndex used by the queue.
Parameters
| Name | Type | Description |
|---|---|---|
max | number | The max zIndex of the queue |
Returns
void
Defined in
src/renderer/renderer.ts:449
setQueueMin
โธ Static setQueueMin(min): void
Sets the minimum zIndex used by the queue.
Parameters
| Name | Type | Description |
|---|---|---|
min | number | The min zIndex of the queue |
Returns
void
Defined in
src/renderer/renderer.ts:458
setResolutionScale
โธ Static setResolutionScale(resolutionScale): void
Sets the resolution scale to use when rendering.
The width and height of the renderer canvas are set to clientWidth * resolutionScale and clientHeight * resolutionScale respectively.
Parameters
| Name | Type | Description |
|---|---|---|
resolutionScale | number | The new resolution scale to use |
Returns
void
Defined in
src/renderer/renderer.ts:341
setScale
โธ Static setScale(scale): void
Set the scale that is applied to vertices to obtain the vertices in clip space.
Parameters
| Name | Type | Description |
|---|---|---|
scale | vec2 | The scaling vector |
Returns
void
Defined in
src/renderer/renderer.ts:404
useCamera
โธ Static useCamera(camera): void
Sets the camera to use for rendering.
Parameters
| Name | Type | Description |
|---|---|---|
camera | Camera | The camera to use for rendering |
Returns
void
Defined in
src/renderer/renderer.ts:386