1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

Keeping animation state between draw()s

Posted by Yan on Dec 05, 2009

Hi,

I noticed that every time draw() is called during animation, it wipes previous frame's state and redraws everything. Is it possible to maintain state from previous frame and only render new objects?

I'm trying to render hundreds of thousands of simple shapes that are stored in pickle'd python objects. Rendering everything without animation locks up NodeBox and makes it hard to infer progress and exhausts virtual memory. Trying to animate it and read next object every frame and deallocating it after displaying throws away all previous frames. My ideal scenario would be to render it as an animation so I can see progress and be able to store the last frame once the rendering is complete.

Is this impossible or am I missing something obvious?


 
Posted by Josh Caswell on Dec 07, 2009

It seems to me that even if you could store the previous frame (which I couldn't figure out in a quick look through the NB source), you would still run out of memory. Unless you rasterize the frame, you've still got to keep the drawing instructions for all those thousands of objects to be redrawn on the next pass. Although you've deallocated the object in your script, NB still has to keep a reference, which means it's still there in memory.

Have you considered trying to draw to a buffer? Something like using AppKit to create your own NSGraphicsContext, and then swapping NB's context for yours might work, but it'll probably be tricky.

Wish I could be more helpful.