Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: About glReadPixel & double buffering

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2004
    Posts
    22

    About glReadPixel & double buffering

    Hi guy,

    in my codes:
    ------------

    glBeing()
    ...
    elEnd()
    glutswapbuffer()

    glBeing()
    ...
    elEnd()
    glutswapbuffer()

    glBeing()
    ...
    elEnd()
    glutswapbuffer()

    glReadpixel(xxx)
    --------------------------

    after 3 x glutswapbuffer(), I found that the framebuffer i got via glreadpixel is not the same as shown on the screen

    What is the reason?

    Should I point to the front buffer or the back buffer?

    In fact, I just want to get the content which shown on the current screen.

    Thanks.

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,527

    Re: About glReadPixel & double buffering

    Put glReadBuffer(GL_FRONT) once before the glReadPixels and you read what you see.
    In double buffered contexts the glDrawBuffer and the glReadBuffer are both defaulting to GL_BACK.

    Some tips:
    After a SwapBuffers don't assume the backbuffer contents to be still valid. There is a hint in the dwFlags of the PIXELFORMATDESCRIPTOR which says if the format copies or can swap, those are named PFD_SWAP_COPY and PFD_SWAP_EXCHANGE.
    Don't assume pixels overlapped by other windows or moved off the desktop to give useful data on readback. Those fail the pixelownership test and are mostly bogus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •