PBuffers and glReadPixels


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,

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

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

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.

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:




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.

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…

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


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.


Sorry for the late reply (WoW has been … stealing my life :stuck_out_tongue: )

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

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.

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…

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.