• Rendering functions, messages and constants. The "render" namespace is accessible only from render scripts.

See RenderMessages for related messages.

Static methods

staticclear(buffers:RenderClearBuffers):Void

  • Clears the active render target.

Clear buffers in the currently enabled render target with specified value.

Parameters:

buffers

Table with keys specifying which buffers to clear and values set to clear values.

@:native("constant_buffer")staticconstantBuffer():RenderConstantBuffer

  • Create a new constant buffer..

Constant buffers are used to set shader program variables and are optionally passed to the Render.draw function. The buffer's constant elements can be indexed like an ordinary Lua table, but you can't iterate over them with pairs() or ipairs().

Returns:

new constant buffer

@:native("delete_render_target")staticdeleteRenderTarget(renderTarget:RenderTarget):Void

  • Deletes a render target.

Parameters:

renderTarget

render target to delete

@:native("disable_material")staticdisableMaterial():Void

  • Disables the currently enabled material.

If a material is currently enabled, disable it.

@:native("disable_state")staticdisableState(state:RenderState):Void

  • Disables a render state.

Parameters:

state

state to enable

@:native("disable_texture")staticdisableTexture(binding:EitherType<Int, HashOrString>):Void

  • Disables a texture for a render target.

Parameters:

unit

texture unit to enable disable for

@:native("dispatch_compute")staticdispatchCompute(x:Int, y:Int, z:Int, ?options:Null<RenderComputeOptions>):Void

  • Dispatch the currently set compute program.

Parameters:

x

Number of workgroups in X

y

Number of workgroups in Y

z

Number of workgroups in Z

options

Optional table with properties (e.g. constants)

staticdraw(predicate:RenderPredicate, ?options:Null<RenderDrawOptions>):Void

  • Draws all objects matching a predicate.

Draws all objects that match a specified predicate. An optional constant buffer can be provided to override the default constants. If no constants buffer is provided, a default system constants buffer is used containing constants as defined in materials and set through *.set_constant() and *.reset_constant() on visual components.

Parameters:

predicate

predicate to draw for

options

optional table with properties

@:native("draw_debug2d")staticdrawDebug2d():Void

Deprecated: "Use `Render.draw_debug3d` to draw visual debug info."
  • Draws all 2d debug graphics (Deprecated).

@:native("draw_debug3d")staticdrawDebug3d(?options:Null<RenderDebugDrawOptions>):Void

  • Draws all 3d debug graphics such as lines drawn with "draw_line" messages and physics visualization.

@:native("enable_material")staticenableMaterial(materialId:HashOrString):Void

  • Enables a material.

If another material was already enabled, it will be automatically disabled.

Parameters:

materialId

material id to enable

@:native("enable_state")staticenableState(state:RenderState):Void

  • Enables a render state.

Parameters:

state

state to enable

@:native("enable_texture")staticenableTexture(binding:EitherType<Int, HashOrString>, handleOrName:EitherType<RenderTarget, TextureResourceHandle>, bufferType:RenderBufferType):Void

  • Enables a texture for a render target.

Parameters:

unit

texture unit to enable texture for

handleOrName

render target from which to enable the specified texture unit

bufferType

buffer type from which to enable the texture

@:native("get_height")staticgetHeight():Int

  • Gets the window height, as specified for the project.

Returns:

specified window height

@:native("get_render_target_height")staticgetRenderTargetHeight(renderTarget:EitherType<RenderTarget, HashOrString>, bufferType:RenderBufferType):Int

  • Retrieve a buffer height from a render target.

Parameters:

renderTarget

render target from which to retrieve the buffer height

bufferType

which type of buffer to retrieve the height from

Returns:

the height of the render target buffer texture

@:native("get_render_target_width")staticgetRenderTargetWidth(renderTarget:EitherType<RenderTarget, HashOrString>, bufferType:RenderBufferType):Int

  • Retrieve a buffer width from a render target.

Parameters:

renderTarget

render target from which to retrieve the buffer width

bufferType

which type of buffer to retrieve the width from

Returns:

the width of the render target buffer texture

@:native("get_width")staticgetWidth():Int

  • Gets the window width, as specified for the project.

Returns:

specified window width

@:native("get_window_height")staticgetWindowHeight():Int

  • Gets the actual window height.

Returns:

actual window height

@:native("get_window_width")staticgetWindowWidth():Int

  • Gets the actual window width.

Returns:

actual window width

staticpredicate(predicates:LuaArray<HashOrString>):RenderPredicate

  • Creates a new render predicate.

This function returns a new render predicate for objects with materials matching the provided material tags. The provided tags are combined into a bit mask for the predicate. If multiple tags are provided, the predicate matches materials with all tags ANDed together.

The current limit to the number of tags that can be defined is 64.

Parameters:

predicates

table of tags that the predicate should match (table).

Returns:

new predicate

@:native("render_target")staticrenderTarget(parameters:Table<RenderBufferType, RenderTargetParameters>):RenderTarget

  • Creates a new render target.

Creates a new render target according to the supplied specification table.

@:native("set_blend_func")staticsetBlendFunc(sourceFactor:RenderBlendFactor, destinationFactor:RenderBlendFactor):Void

  • Sets the blending function.

Parameters:

sourceFactor

source factor

destinationFactor

destination factor

@:native("set_camera")staticsetCamera(?camera:Null<HashOrString>, ?options:Null<SetCameraOptions>):Void

  • Set or reset the active camera for rendering.

Parameters:

camera

Optional camera id to use. Omit or set to null to reset.

options

Optional table with behaviour parameters.

@:native("set_color_mask")staticsetColorMask(red:Bool, green:Bool, blue:Bool, alpha:Bool):Void

  • Sets the color mask.

Parameters:

red

red mask

green

green mask

blue

blue mask

alpha

alpha mask

@:native("set_compute")staticsetCompute(?compute:Null<HashOrString>):Void

  • Set or reset a compute program.

Parameters:

compute

Optional compute program to set. Omit or set to null to disable.

@:native("set_cull_face")staticsetCullFace(faceType:RenderCullFaceType):Void

  • Sets the cull face.

Parameters:

faceType

face type

@:native("set_depth_func")staticsetDepthFunc(func:RenderCompareFunc):Void

  • Sets the depth test function.

Parameters:

func

depth test function

@:native("set_depth_mask")staticsetDepthMask(depth:Bool):Void

  • Sets the depth mask.

Parameters:

depth

depth mask

@:native("set_listener")staticsetListener(?callback:RenderContextEvent ‑> Void):Void

  • Set a listener for render context events.

Parameters:

callback

Optional callback function. Omit or set to null to remove listener.

@:native("set_polygon_offset")staticsetPolygonOffset(factor:Float, units:Float):Void

  • Sets the polygon offset.

Parameters:

factor

polygon offset factor

units

polygon offset units

@:native("set_projection")staticsetProjection(matrix:Matrix4):Void

  • Sets the projection matrix to use when rendering.

Parameters:

matrix

projection matrix

@:native("set_render_target")staticsetRenderTarget(renderarget:EitherType<RenderTarget, HashOrString>, ?options:Null<SetRenderTargetOptions>):Void

  • Sets a render target. Subsequent draw operations will be to the render target until it is replaced by a subsequent call to set_render_target.

Parameters:

renderarget

render target to set. RenderTarget.Default to set the default render target

options

optional table with behaviour parameters

@:native("set_render_target_size")staticsetRenderTargetSize(renderarget:EitherType<RenderTarget, HashOrString>, width:Int, height:Int):Void

  • Sets the render target size.

Parameters:

renderarget

render target to set size for

width

new render target width

height

new render target height

@:native("set_stencil_func")staticsetStencilFunc(func:RenderCompareFunc, ref:Float, mask:Int):Void

  • Sets the stencil test function.

Parameters:

func

stencil test function

ref

reference value for the stencil test

mask

mask that is ANDed with both the reference value and the stored stencil value when the test is done

@:native("set_stencil_mask")staticsetStencilMask(mask:Int):Void

  • Sets the stencil mask.

Parameters:

mask

stencil mask (number)

@:native("set_stencil_op")staticsetStencilOp(sfail:RenderStencilOp, dpfail:RenderStencilOp, dppass:RenderStencilOp):Void

  • Sets the stencil operator.

Parameters:

sfail

action to take when the stencil test fails

dpfail

the stencil action when the stencil test passes

dppass

the stencil action when both the stencil test and the depth test pass, or when the stencil test passes and either there is no depth buffer or depth testing is not enabled

@:native("set_view")staticsetView(matrix:Matrix4):Void

  • Sets the view matrix to use when rendering.

Parameters:

matrix

view matrix to set

@:native("set_viewport")staticsetViewport(x:Int, y:Int, width:Int, height:Int):Void

  • Sets the render viewport.

Parameters:

x

left corner

y

bottom corner

width

viewport width

height

viewport height