Don't draw background everytime in the drawing loop

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 .

show some code, maybe we can help you out.

:regards:

Originally posted by ce110ut:
[b]show some code, maybe we can help you out.

:regards:[/b]
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?

just an idea (probably wrong :stuck_out_tongue: )… 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.

Originally posted by miko:
[b]just an idea (probably wrong :stuck_out_tongue: )… 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.[/b]
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.

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.