pbrown:
I personally think this is very important functionality that I’d like to see in an OpenGL 1.5, OpenGL 2.0, or whatever you want to call it.
I fully agree, but I also would like to clarify one thing:
The closest thing in “GL2” whitepapers appears to be image buffers in the memory management whitepapers, but it doesn’t seem to be obviously connected to render texture, pbuffers, and the like
“OpenGL 2.0 Objects” v1.2 paper describes glAttach/DetachBufferObject() functions, which could allow achieving the same affects as with DX9’s SetRenderTarget().
This is how, according to the proposal, RTT with sharing depth+stencil buffer might look like:
// initialisation:
GLhandle WindowFrameBuffer = glCreateFrameBufferObject(…); /* main FB /
GLhandle OffscreenFrameBuffer = glCreateFrameBufferObject(…); / ‘pbuffer’ */
GLhandle DepthAndStencilBuffer = glCreateBufferObject(GL_DEPTH, …);
GLhandle RenderTexture = glCreateTextureObject(…)
GLhandle OffscreenColorBuffer = /* acquire GL_FRONT_LEFT_BUFFER_HANDLE from the
OffscreenFrameBuffer, proposal doesn’t say
how to do this, there is no GetObjectParameter()
returning values of GLhandle type */
glAttachImageObject(RenderTexture, OffscreenColorBuffer, 0);
(…)
// rendering loop:
{
// dettach depth+stencil from the window:
glDetachObject(WindowFrameBuffer, DepthAndStencilBuffer);
// attach depth+stencil to the ‘pbuffer’:
glAttachBufferObject(OffscreenFrameBuffer, DepthAndStencilBuffer);
// set render target:
glUseFrameBufferObject(GL_DRAW, OffscreenFrameBuffer);
// now render to the ‘pbuffer’
(…)
// dettach depth+stencil from the 'pbuffer':
glDetachObject(OffscreenFrameBuffer, DepthAndStencilBuffer);
// attach depth+stencil to the window
glAttachBufferObject(WindowFrameBuffer, DepthAndStencilBuffer);
// set render target:
glUseFrameBufferObject(GL_DRAW, WindowFrameBuffer);
// now render to the window
(…)
// bind the ‘pbuffer’ as texture:
glUseTextureObject(RenderTexture, /texture unit/);
(…)
}
IMO GL2 proposal includes solutions for all RTT-related problems i’m aware now.