---- Reported by tedmunds 2005-06-05 13:00:44 ---- The current render-to-texture functionality makes use of the WGL_ARB_render_texture extension to allow a Pbuffer's colour buffer to be bound to a texture. It would also be useful to be able to use the WGL_NV_render_depth_texture extension to allow binding of the Pbuffer's depth buffer to a depth texture. The implementation of such a feature (on Windows) could parallel the already present render-to-texture functionality. An example of such an implementation is available at http://www.cs.rutgers.edu/~tedmunds/jogl/renderToDepthTexture.zip. The implementation makes the following modifications to the JOGL code base: net.java.games.jogl.GLCapabilities: * Add a boolean field offscreenRenderToDepthTexture (similar to offscreenRenderToTexture) that indicates whether the created Pbuffer should allow render-to-depth-texture. * Add accessors (getOffscreenRenderToDepthTexture(), setOffscreenRenderToDepthTexture(boolean onOrOff) for the above field. net.java.games.jogl.GLPbuffer: * Add a method bindDepthTexture() (similar to bindTexture()) that calls for the Pbuffer's depth buffer to be bound to GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE_NV. * Add a method releaseDepthTexture() that parallel's depthTexture(). net.java.games.jogl.impl.GLPbufferImpl: * Implement the added GLPbuffer interface methods (above) by calling the corresponding methods on the context (below) net.java.games.jogl.impl.GLContext: * Add an abstract method bindPbufferToDepthTexture() (similar to bindPbufferToTexture()). * Add an abstract method releasePbufferFromDepthTexture() (similar to releasePbufferFromTexture()). net.java.games.jogl.impl.windows.OffscreenGLContext/OnscreenGLContext: * Implement the added GLContext abstract methods (above) with versions that throw exceptions indicating that they should not be called. net.java.games.jogl.impl.windows.WindowsPbufferGLContext: * Add a field rtdt (similar to rtt) indicating whether render-to-depth-texture is enabled. * Add a field hasRTDT (similar to RTDT) indicating whether the render-to-depth-texture extension is available. * Add a field depthTexture (similar to texture) that holds the texture object ID of the depth texture. * Modify the constructor's DEBUG output to include rtdt. * Implement bindPbufferToDepthTexture() in a manner similar to bindPbufferToTexture(), except that the wglBindTexImageARB() call binds to WGL_DEPTH_COMPONENT_NV instead of WGL_FRONT_LEFT_ARB. * Implement releasePbufferFromDepthTexture() (with the same relationship to releasePbufferFromTexture()). * Modify createPbuffer(long, long): * Initialize rtdt from the capabilities. * On many of the tests that check whether rtt == true, modify to check whether (rtt || rtdt) == true. * If rtdt, add to the iattributes array the pair: WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV or WGL_BIND_TO_TEXTURE_DEPTH_NV (depending on rect) and GL_TRUE (to enable binding of the depth buffer to a texture). * In the NVidia work-around loop, if rtdt, add the WGL_DEPTH_TEXTURE_FORMAT_NV and WGL_TEXTURE_DEPTH_COMPONENT_NV pair to the iattributes array. * Modify makeCurrent(Runnable): * Initialize rtdt from the capabilities. * Determine the render-to-texture-rectangle settings if rtt or rtdt is true. * If rtdt: * Determine whether the render-to-depth-texture extension is available. * Generate a texture to be bound to the depth buffer. * Bind the generated texture to the texture target. * Configure the texture lookup parameters. * Choose the internal format of the texture (one of the depth formats) * Create the texture with null contents. * Modify swapBuffers(): * If render-to-depth-texture is enabled (rtdt), but the extension is not available (!hasRTDT), copy the depth buffer to the depth texture. * In both the new copying case and the existing colour buffer copy, bind the appropriate texture to the texture target before copying. net.java.games.jogl.impl.macosx.MacOSX*GLContext: net.java.games.jogl.impl.x11.X11*GLContext: * Not yet implemented (methods added with comments/exceptions to that effect) Design decisions: * By paralleling render-to-depth-texture alongside render-to-texture, it is possible to bind both the colour buffer and the depth buffer of a Pbuffer to (different) textures. * For simplicity, the existing render-to-texture-rect settings are made to apply to both the colour and depth textures. It should be possible to allow (eg.) the colour buffer to be bound to GL_TEXTURE_RECTANGLE_NV, and the depth buffer to be bound to GL_TEXTURE_2D, but it doesn't seem that useful. Notes: * The example patch was created against the latest source from CVS as of June 4, 2005. * As well as implementing the described render-to-depth-texture functionality, the example patch implements the exposure of the texture target (i.e. allowing the API programmer to determine whether the buffers are bound to GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE_NV. * Also included in the source archive is and example application (RenderToTexture.java) that demonstrates the combined use of render-to-texture and render-to-depth-texture. ---- Additional Comments From kbr 2005-06-22 01:14:32 ---- Thanks for the suggestion and patch. However, the OpenGL community is moving away from pbuffers and toward the frame buffer object extension, which is a more portable and higher-performance solution for offscreen rendering than pbuffers. I'm therefore reluctant to enhance JOGL's pbuffer implementation significantly at this time, because we're trying to stabilize the final release of the current JOGL APIs. Your patch will be considered for a future version of JOGL implementing the JSR-231 APIs. ---- Additional Comments From tedmunds 2006-02-07 14:27:13 ---- Created an attachment Framebuffer object implementation of the desired functionality. --- Bug imported by sgothel@jausoft.com 2010-03-24 07:47 EDT --- This bug was previously known as _bug_ 163 at https://jogl.dev.java.net/bugs/show_bug.cgi?id=163 Imported an attachment (id=57) Bug has invalid status, setting status to "NEW". Previous status was "STARTED". The original submitter of attachment 57 [details] is unknown. Reassigning to the person who moved it here: sgothel@jausoft.com.