isolatedWithTarget

fun Drawer.isolatedWithTarget(target: RenderTarget, function: Drawer.() -> Unit)(source)

Executes the given function within an isolated drawing context bound to the specified render target.

This method binds the provided render target, executes the function within an isolated context, and then ensures that the render target is unbound after execution.

Usage example:

val rt = renderTarget(100, 100) {
colorBuffer()
depthBuffer()
}
drawer.fill = ColorRGBa.PINK
drawer.isolatedWithTarget(rt) {
// set a new projection transform
drawer.ortho(rt)
drawer.fill = ColorRGBa.BLACK
drawer.translate(100.0, 100.0)
drawer.circle(0.0, 0.0, 50.0)
}
drawer.image(rt.colorBuffer(0))
// close the render target to free up resources
rt.close()

Parameters

target

The render target to bind during the execution of the provided function.

function

The drawing function to execute within the isolated context.

See also