Hi all, I have a redraw routine in my js code that executes:
This obviously clears whole screen and redraws each time i bang it. It there anyway to invalidate portions of the screen rather than erasing the whole lot so that it knows it only has to draw the portions that have changed?
I think i’ve sussed out what is needed and that is to turn autodraw off for each component, and call draw myself when i need to draw, but not sure how this fits in with what needs to be sent to the renderer. getting lots of flashing and no erasing under the objects. what is the generic process for handling drawing of own objects rather than using autodraw?
Ok, i’ve got the non-autodraw stuff working but I’m still having to call render.erase() to get things working. this is obviously still clearing the whole screen which means items i’m not updating in this refresh are not been redrawn. is there anyway i can just erase the bits which I am about to redraw rather than erasing the whole screen? thx Lee
Hi. Anyone got any advice on this?
My impression is that you are working on a faulty assumption of how OpenGL drawing works. One way to think of your color-buffer is like a painting. When openGL renders some geometry, it paints the color buffer pixels a different color. If you then render other geometry, that paints over the appropriate pixels in the color-buffer. The color-buffer accumulates all of this drawing and then displays it on screen. When you send an "erase" message to the context, what it actually does is paint-fill the entire color-buffer with the erase_color. This is why erase_color with alpha less than 1 leaves traces of the previous frame.
Why are you trying to avoid drawing objects? Are you experiencing slow framerates?
Hi. No, not experiencing slow frame rates, experiencing high cpu. For every frame I’m drawing there are ~150 gridshape objects and ~120 text objects. Most of these don’t change, but I’m constantly erasing and redrawing them with auto on. i did some playing around where i just redrew about 10-20 of the objects each frame (which is realistically what is likely to be changing) and the cpu dropped 4-5% so I only really want to redraw the objects that have changed (via an explicit draw() call) rather than having autoddraw on.
If I have doublebuffer on and remove the call to erase() and just call drawclients() then the screen is totally blank (unexpected). If I call drawclients() and swap() then I get a frame and a blank frame. If I call erase() before drawclients() then followed by swap() I get a solid screen. So it seems to me that erase() is having some effect on what is going on (unexpected).
Am currently exploring what happens with doublebuffering turned off.
Forums > Jitter