Bug 163 - Extend Render-to-Texture functionality to include Render-to-Depth-Texture
Summary: Extend Render-to-Texture functionality to include Render-to-Depth-Texture
Alias: None
Product: Jogl
Classification: JogAmp
Component: core (show other bugs)
Version: 1
Hardware: All all
: P4 normal
Assignee: Sven Gothel
URL: http://www.cs.rutgers.edu/~tedmunds/j...
Depends on:
Reported: 2005-06-05 01:00 CEST by Sven Gothel
Modified: 2015-09-27 03:09 CEST (History)
0 users

See Also:
SCM Refs:
Workaround: ---

Framebuffer object implementation of the desired functionality. (18.25 KB, text/plain)
2006-02-07 14:27 CET, Sven Gothel

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Gothel 2010-03-24 07:47:51 CET

---- 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

The implementation makes the following modifications to the JOGL code base:
  * 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.
  * Add a method bindDepthTexture() (similar to bindTexture()) that calls for
    the Pbuffer's depth buffer to be bound to GL_TEXTURE_2D or
  * Add a method releaseDepthTexture() that parallel's depthTexture().
  * Implement the added GLPbuffer interface methods (above) by calling the
    corresponding methods on the context (below)
  * Add an abstract method bindPbufferToDepthTexture() (similar to
  * Add an abstract method releasePbufferFromDepthTexture() (similar to
  * Implement the added GLContext abstract methods (above) with versions that
    throw exceptions indicating that they should not be called.
  * 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
  * Implement releasePbufferFromDepthTexture() (with the same relationship to
  * 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_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
      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.
  * 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.

  * 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
  * 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.