glReadPixels gives only black...

I want to make screenshots in my engine and I’m trying this via glReadPixels. The thing is, that when I call the function, my buffer only gets filled black pixels. I tried glReadBuffer with back and front, as well as calling the function at different rendering stages (i.e. after or before calling swapbuffers) - to no avail.
I use this:
BYTE *pData = new BYTE[m_cx * m_cy * 3];
glReadPixels(0, m_cy-1, m_cx, m_cy, GL_RGB, GL_UNSIGNED_BYTE, pData);

with m_cx and m_cy being the window sizes.

What am I doing wrong?


glReadPixels(0, 0, m_cx, m_cy, GL_RGB, GL_UNSIGNED_BYTE, pData);

you should be reading from the front buffer.

Thanks! That did the trick.
Very strange - I had systematically tried all possible combinations, including your proposition, before posting but I still got a blank screen - I guess I messed something different up while testing. shrug
Anyway, it works now…

So the “lower left corner” in the red book is to be interpreted thus, that the lower left corner of the image is (0,0) - the origin of the picture - and, in effect, if I read any picture data from the framebuffer, I get it upside down?


Probably you’re running in software, not hardware.
Test the result of GL_RENDERER, “Generic…” means you’re running in software.