Skip to content
Robert Konrad edited this page Jul 8, 2015 · 3 revisions

Render to texture is a handy feature which lets us draw stuff into image and then use resulting image instead of redrawing said stuff every frame. This can be used to speed up rendering, perform shader effects,...

To begin, create an image of desired size using Image.createRenderTarget(). You can then draw to this image as you would into framebuffer - for example by image.g2(2D) or image.g4(3D). When you are done, don't forget to draw the image itself into framebuffer.

var image = Image.createRenderTarget(256, 256);
var g = image.g2;
g.begin(); // sets up everything for rendering into the texture
g.color = Color.Red;
g.fillRect(20, 20, 50, 50);
g.end(); // after the end call, the image can be used just like any other image
Clone this wiki locally