Results 1 to 6 of 6

Thread: Copying the depth and color buffer?

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2006
    Location
    Germany
    Posts
    3

    Copying the depth and color buffer?

    Hi,

    I render a scene which may consist of up to 50 million triangles, so the rendering may take a while. Upon that rendered scene, I want to do some interactive "drawing", f. ex. the user moves his mouse over the scene and additional things like a polyline will be rendered additionally onto the basic scene.

    Since I want to avoid to re-render the large scene each time the user moves his mouse, I thought of rendering the basic scene first, storing the depth and color buffer, and on each mouse motion, copy these buffers back and then do the additional drawing commands.

    The software must work on several cards, so I cannot use hardware-dependant code.
    Do you think that using glReadPixels/glDrawPixels is the best way or are there better alternatives?

    Thanks,
    Matthias

  2. #2
    V-man
    Guest

    Re: Copying the depth and color buffer?

    The best is WGL_ARB_buffer_region but this is just an extension so not all cards support it.
    glReadPixels/glDrawPixels is the next option.

    You might want to simply your scene since 50 million triangles are not likely to be visible on screen.

    Try to use formats the hw prefers

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2006
    Location
    Germany
    Posts
    3

    Re: Copying the depth and color buffer?

    Unfortunately I can't use hw specific code.

    glReadPixels/glDrawPixels works fine for the color-buffer, but when I try to restore the depth buffer, I have problems; glDrawPixels seems to draw into the color buffer even when GL_DEPTH_COMPONENT is used.

    Any hints how I can save and restore the depthbuffer?

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,662

    Re: Copying the depth and color buffer?

    For the depth buffer, from what you said I guess the best solution would simply be not to clear it at all.

    Another solution: you can try to use FBOs. Render your scene first in a FBO then copy the image into the front buffer each time you need it.

  5. #5
    Senior Member Frequent Contributor arekkusu's Avatar
    Join Date
    Nov 2003
    Posts
    890

    Re: Copying the depth and color buffer?

    DrawPixels always draws fragment groups (color/depth/stencil). It is up to you to mask off the parts you don't want, with Disable for depth/stencil and ColorMask for color.

  6. #6
    Junior Member Newbie
    Join Date
    Sep 2006
    Location
    Germany
    Posts
    3

    Re: Copying the depth and color buffer?

    arekkusu,
    thanks, now it works!

    jide,
    not clearing the buffer means that I must not modify it if I want to use it several times; this has some unwanted effects...

    Thanks all for you help!

Similar Threads

  1. Copying Depth Buffer To Texture
    By asafc in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 11-25-2009, 10:44 AM
  2. Copying Depth Buffer To Texture.
    By PickleWorld in forum OpenGL: Advanced Coding
    Replies: 14
    Last Post: 03-06-2009, 12:01 AM
  3. Replies: 5
    Last Post: 02-10-2006, 12:56 PM
  4. Copying Depth Buffer
    By drewT in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 04-09-2003, 01:09 AM
  5. Copying the depth buffer
    By Hamdinger in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 06-09-2000, 01:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean