Persistance in Layers

Skip to first unread message


Jun 22, 2011, 10:31:17 PM6/22/11
to NodeBox for OpenGL

I have been playing a bit with NodeBox for OpenGL and it is a very
nice framework.

Regarding Layers, when overriding the draw() method the canvas is
automatically cleared, so there is always a new drawing on each frame.
I wonder how can make a layer persist, so each new frame is drawn on
top of the previous one, as it is the default behaviour of the main
draw() function, where you have to clear the canvas manually if you
don't want persistence. This feature is important as it is not
practical to re-draw hundreds of static elements on each frame; it
would be nice to just draw the new ones.

Thank you.

Tom De Smedt

Jun 29, 2011, 7:27:27 PM6/29/11
to NodeBox for OpenGL
The default Canvas.draw() clears the frame. If you append layers but
don't implement your own Canvas.draw(), the default is used. You can
patch the canvas with an empty draw(), so that layers will persist:

canvas.size = 800, 600 canvas: None)

(or something along those lines, I haven't tested it)

Note that all layers draw "to the canvas", not "inside themselves". To
use a Photoshop metaphor: all layers are flattened before you get to
see anything. If you need a few layers to be persistent, but other
layers that clear each frame, you need to draw each of them to
separate OffscreenBuffer objects. There are some docs + examples on
this topic but feel free to ask if you need more help.

Reply all
Reply to author
0 new messages