PDA

View Full Version : Don't draw background everytime in the drawing loop



Sourpotato
05-20-2004, 07:12 PM
the background picture rendering slow my application greatly.
and background picture seldom changes and update in the rendering loop.
how can do to make the background is not erased and redrawed every time in the opengl drawing loop .

ce110ut
05-20-2004, 08:43 PM
show some code, maybe we can help you out.

:regards:

Sourpotato
05-20-2004, 09:00 PM
Originally posted by ce110ut:
show some code, maybe we can help you out.

:regards:Thanx for attention, here goes the code rather descriptive



void OGLRender::DrawAll()
{
glClear();
funcion()...//set the ortho projection
Render2D(); // this part slow down the app,and the things the 2d draw seldom change
function() ... //set the perspective projection;
Render3D();
}Render2D part is what i focused to optimize.

i have tried to use glScissor before Render2D,thus, we don't need to Render2D everytime. however glScissor make the whole window display rather messy.Any suggestions?

miko
05-21-2004, 08:19 AM
just an idea (probably wrong :p )... how are rendering your background image. i thing when you reder is as 16 (or any other number) quads it should be ok (compare it with number of polygons in foreground!). maybe you're using glDrawPixels or something, don't do it (it's awfuly slow - at least on my hardware).

if your background image is not just plain bitmap but something more complex render it only once and then store to memeory.

Sourpotato
05-22-2004, 06:25 AM
Originally posted by miko:
just an idea (probably wrong :p )... how are rendering your background image. i thing when you reder is as 16 (or any other number) quads it should be ok (compare it with number of polygons in foreground!). maybe you're using glDrawPixels or something, don't do it (it's awfuly slow - at least on my hardware).

if your background image is not just plain bitmap but something more complex render it only once and then store to memeory.Don't i don't use the glDrawPixels, simply put the texture on the quads and a lot of texts on the background. what do you mean that i put it into the memory.

miko
05-25-2004, 01:42 AM
when your background changes draw it then call glFlush. then you may may retrieve framebuffer using glReadPixels (slooooow, at least on my hardware) or few calls to glCopyTexImage2D (i don't know how fast is this but it should be good). on subsequent frames just render few quads covered with your new textures. note this assumes your background changes really rarely.

hope this helps.