Redrawing screen

Jun 1, 2012 at 2:54pm

Redrawing screen

Hi all, I have a redraw routine in my js code that executes:

render.erase();
render.drawswap();

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?

thanks, L

#56472
Jun 2, 2012 at 5:28pm

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?

thx

#202469
Jun 2, 2012 at 5:56pm

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

#202470
Jun 4, 2012 at 11:31am

Hi. Anyone got any advice on this?

#202471
Jun 5, 2012 at 11:49pm

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?

#202472
Jun 8, 2012 at 8:06pm

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.

#202473

You must be logged in to reply to this topic.