View Full Version : Having to redraw after FrameBuffer

05-24-2006, 11:02 PM

I have just set up a frame buffer in my program. I draw a scene, then I use it as a texture. What I want is to be able to keep the scene that was rendered in the framebuffer so that I do not have to draw everything again.

So I have a terrain that I draw it in the frame buffer. I then apply it as a texture to what will be my water.

The problem is that I do not want to have to redraw the terrain again as this is computationally expensive. Can I keep the frame buffer content as the image on the screen as well as using it as a texture?

Zulfiqar Malik
05-25-2006, 12:48 AM
If you do not clear it then it will "remain there" :) . On the other hand you can render the terrain to a render target and use the render target texture on a screen aligned quad (and render to framebuffer ofcourse) whenever u do not want to render the terrain again.

05-25-2006, 12:57 AM
I have tried not clearing it. It causes everything to be redrawn over itself.

I am clearing it when I switch to the FrameBuffer at the start, then when I switch to the current Buffer (the visible one), I try not clearing it, and it then redraws over the previous image still showing part of the previous image.

So not clearing, does not seem to work :(

05-25-2006, 01:38 AM
So why you can't simply draw terrain, then copy-back screen texture, and after draw water? Depth buffer is prefilled with terrain, so, everything will be just OK.
Actually, I know lots of people, who do so, as you described. And do litke this also.
I don't see any difficulties.

Ahh, I got your problem, you render terrain into another frame buffer, right? Not system screen frame buffer? So, you can't do as you want to.
The reason is you have to prefill depth-buffer with terrain values for correct fragment ordering.

May be, you can try the following:
- render you terrain to downscaled resolution FBO to save the fillrate
- render it with lower geometric complexity to save GPU processing time
- render it with some simplified shader also.

05-25-2006, 03:39 AM
So I am going to have to redraw my terrain if I choose to keep this other frame buffer.

I think I will just go with glGenTexSubImage (doesn't look to be spelt right :p ) command.

It is easier :p And also faster....