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

Thread: PBuffers and glReadPixels

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    27

    PBuffers and glReadPixels

    Hi,

    I seem to be having some troubles with reading pixels from a PBuffer. Or perhaps I'm having troubles drawing to the PBuffer in the first place (although unlikely).

    I'm currently creating the PBuffer successfuly, and binding it via glXMakeCurrent, which is also successfull. I then render to hte PBuffer and call glReadPixels(0, 0, 512, 512, GL_RGB, GL_FLOAT, pixels), which unfortinately returns all black pixels. however if i render the same data to the back buffer and call the same function, it reads the pixel data correctly...

    I'm 99% sure i'm creating and binding the PBuffer correctly, i'm just wondering if there's anything special I have to take into consideration for glReadPixels to work...

    Thanks in advance,
    Smokey`

  2. #2
    Junior Member Newbie
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    27

    Re: PBuffers and glReadPixels

    Oh, I should also note that the PBuffer i successfully create is a preserved PBuffer... so technically i should not have to lock X...

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    27

    Re: PBuffers and glReadPixels

    Alright, I also forgot to mention that it's a floating point PBuffer using GLX_FLOAT_COMPONENTS_NV... now as i said before i can create it and bind it perfectly, however when i draw to it, then read the pixels back, they come back corrupted, sort of as if it only gets the top few pixels of the screen, and keeps repeating it almost all the way down... but even the top few pixels are somewhat corrupted... *sighs*

    Edit:
    Upon further inspection it seems that everything is working perfectly, however the PBuffer being created is alot smaller than I requested... I requested a 512^2 floating point PBuffer, however it seems i only really got a 64^2 PBuffer - but it's somehow treating it like a 512^2 PBuffer... I've come to this conclusion because if i ask for a 64^2 floating point PBuffer it works perfectly, 128^2 looks like it overlaps half way, etc, etc, etc...

    Once again any help would be great.

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

    Re: PBuffers and glReadPixels

    Unfortunately I haven't done any pbuffering yet. And I wonder if I will some day.

    So, I had a quick look on a search engine and found that:

    http://oss.sgi.com/projects/ogl-samp...IX/pbuffer.txt

    http://www.paulsprojects.net/opengl/rtotex/rtotex.html

    http://www.talkaboutgraphics.com/gro...es/135912.html

    Even if I think you already have looked at them, the fact that you tell you have problems with sizes makes me wonder if you read well the first.
    A very quick look makes me see that you can wonder the max sizes of your pbuffer among other things that might also help you.

    Hope this helps.

  5. #5
    Junior Member Newbie
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    27

    Re: PBuffers and glReadPixels

    Let me quickly update, i'm sorry I didnt say this earlier, normal 32bit RGBA pbuffers work perfectly, however it's floating point PBuffers that are giving me troubles...

  6. #6
    Junior Member Newbie
    Join Date
    Feb 2005
    Posts
    23

    Re: PBuffers and glReadPixels

    It looks like you are using the NV_float_buffer extension.
    Check out the spec.

    NV_float_buffer

    It mentions the following.

    The following extensions are required:
    * NV_fragment_program
    * NV_texture_rectangle
    * WGL_ARB_pixel_format
    * WGL_ARB_render_texture
    * WGL_NV_render_texture_rectangle

    I think you may have to have a fragment program enabled when rendering to the float pbuffer, even if it does nothing more than pass through the fragment.

    -VC

  7. #7
    Junior Member Newbie
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    27

    Re: PBuffers and glReadPixels

    Sorry for the late reply (WoW has been ... stealing my life )

    Rendering using a fragment shader doesnt change anything, still the same output.

    EDIT:
    Okay, mysteriously after 10 days of WoW, I have the same problem with fixed point PBuffers too... Except floating point PBuffers are a little bit corrupt...

    Also, nVidia's simple_pbuffer example suffers from the same problem.

  8. #8
    Junior Member Newbie
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    27

    Re: PBuffers and glReadPixels

    Okay, i've resolved the issue completely, and it had nothing to do with pixel buffers. The problem is with glReadPixels and glDrawPixels, one or both are not working properly, both my code and nVidia's simple_pbuffer example have the exact same problems. However both of our code using a a textured quad with a texture created from glCopyTexSubImage2D from the pbuffer, work perfectly...

    *sigh* there goes almost 2 weeks of wasted trial and error because of two functions not working the qay they're doucmented to...

Posting Permissions

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