Class

RenderAPI

RenderAPI()

A rendering API

Constructor

new RenderAPI()

Web technologies allow Canvas and WebGL rendering

View Source Renderers/RenderAPI.js, line 7

Members

Camera

protected activeCamera

Camera to use for next draw calls and graphics calculs

View Source Renderers/RenderAPI.js, line 18

Methods

applyStateBlock(stateBlock)

Apply the given state block
Parameters:
Name Type Description
stateBlock StateBlock A StateBlock instance

View Source Renderers/RenderAPI.js, line 33

bindFrameBuffer(framebufferID)

Bind the given framebuffer
Parameters:
Name Type Description
framebufferID number An identifier, -1 to bind the default frame buffer

View Source Renderers/RenderAPI.js, line 47

bindLight(light)

Bind light
Parameters:
Name Type Description
light Light A Light instance

View Source Renderers/RenderAPI.js, line 26

bindTexture(slot, texture)

Bind texture to the the given slot
Parameters:
Name Type Description
slot number Targeted slot's index
texture TextureInterface A Texture instance

View Source Renderers/RenderAPI.js, line 55

bindTextureCube(slot, texture)

Bind texture cube to the the given slot
Parameters:
Name Type Description
slot number Targeted slot's index
texture TextureCube A TextureCube instance

View Source Renderers/RenderAPI.js, line 63

clear(color)

Clear the rendering target
Parameters:
Name Type Description
color Color A Color instance

View Source Renderers/RenderAPI.js, line 70

clearCache()

Clear cache

View Source Renderers/RenderAPI.js, line 75

createFrameBuffer() → {number}

Create a new frame buffer

View Source Renderers/RenderAPI.js, line 82

An identifier to work with it later
number

drawIndexedPrimitives(drawingMode, firstVertexIndex, vertexCount)

Draw indexed primitives
Parameters:
Name Type Description
drawingMode DrawingMode Drawing mode to use
firstVertexIndex number Index of the first vertex to draw, useful to draw some parts
vertexCount number Vertex count to draw

View Source Renderers/RenderAPI.js, line 91

drawPrimitives(drawingMode, firstVertexIndex, vertexCount)

Draw primitives
Parameters:
Name Type Description
drawingMode DrawingMode Drawing mode to use
firstVertexIndex number Index of the first vertex to draw, useful to draw some parts
vertexCount number Vertex count to draw

View Source Renderers/RenderAPI.js, line 100

getActiveCamera() → {Camera}

Get the active camera

View Source Renderers/RenderAPI.js, line 235

A Camera instance or null
Camera

initFrameBuffer(framebufferID, textures, useDepthBufferopt, useStencilBufferopt)

Init frame buffer: attach it to textures, depth buffer and/or a stencil buffer
Parameters:
Name Type Attributes Default Description
framebufferID number Targeted slot's index
textures Array.<Texture> An array of Texture instances
useDepthBuffer boolean <optional>
true True to use a depth buffer
useStencilBuffer boolean <optional>
false True to use a depth buffer

View Source Renderers/RenderAPI.js, line 110

setActiveCamera(camera)

Set camera to use
Parameters:
Name Type Description
camera Camera A Camera instance

View Source Renderers/RenderAPI.js, line 117

setBlendMode(blendMode)

Set blend mode to apply
Parameters:
Name Type Description
blendMode BlendMode A BlendMode instance

View Source Renderers/RenderAPI.js, line 126

setDepthState(depthTest, writeTest, depthFunction)

Set depth state
Parameters:
Name Type Description
depthTest boolean True to activate depth testing, otherwise false
writeTest boolean True to activate depth writing otherwise false
depthFunction DepthFunction Depth function to apply

View Source Renderers/RenderAPI.js, line 135

setFaceCulling(mode)

Set face culling state.
Parameters:
Name Type Description
mode FaceCulling Face culling mode to set.

View Source Renderers/RenderAPI.js, line 141

setGeometry(geometry)

Set geometry to use
Parameters:
Name Type Description
geometry Geometry A Geometry instance

View Source Renderers/RenderAPI.js, line 148

setIndexBuffer(buffer)

Set index buffer to use
Parameters:
Name Type Description
buffer number | WebGLBuffer A buffer instance

View Source Renderers/RenderAPI.js, line 155

setProgram(program) → {number}

Set program to use
Parameters:
Name Type Description
program Program A Program instance to use

View Source Renderers/RenderAPI.js, line 163

-1: an error occured, 0: everything is ok, 2 : program have been changed
number

setScissorTest(state, x, y, w, h)

Set scissor test state
Parameters:
Name Type Description
state boolean True to activate scissor testing, otherwise false
x number Position on x from the left of the screen
y number Position on y from the bottom of the screen
w number Width of the rectangle
h number Height of the rectangle

View Source Renderers/RenderAPI.js, line 186

setStencilFunction(stencilFunction, reference, mask)

Set stencil function to use
Parameters:
Name Type Description
stencilFunction StencilFunction Function to use
reference number Reference value
mask number Mask to use

View Source Renderers/RenderAPI.js, line 203

setStencilOperations(sFail, dpFail, dppPass)

Set stencil operations to use
Parameters:
Name Type Description
sFail StencilOperation Function to use
dpFail StencilOperation Reference value
dppPass StencilOperation Mask to use

View Source Renderers/RenderAPI.js, line 212

setStencilState(activate, writeMask)

Set stencil test state
Parameters:
Name Type Description
activate boolean True to active stencil testing, otherwise false
writeMask number Stencil writing value

View Source Renderers/RenderAPI.js, line 194

setUniform(program, name, type, value, groupCountopt) → {boolean}

Set uniform value
Parameters:
Name Type Attributes Description
program Program A Program instance to use
name string Uniform's name
type Type Type of value to send
value ?Array.<number> | Texture | boolean | number | Float32Array A value
groupCount number <optional>
When an element is an array, you can create group (like sub-array)

View Source Renderers/RenderAPI.js, line 175

True if uniform has been set successfully, otherwise false
boolean

setVertexBuffer(stream, buffer)

Set vertex buffer to use Warning: You must call "setVertexFormat" before!
Parameters:
Name Type Description
stream number An integer representing stream to use
buffer number | WebGLBuffer A buffer instance

View Source Renderers/RenderAPI.js, line 221

setVertexFormat(format)

Set vertex format to use
Parameters:
Name Type Description
format VertexFormat A VertexFormat instance

View Source Renderers/RenderAPI.js, line 228