What am I doing wrong? I run the following code to grab the contents of the frame buffer running my application in a window. w_, h_ denotes width, height of my window. I am using double buffering and do my grab just before I swap buffers. doing it after does not seem to make any change. My problem is that i get some other part of the screen or sometimes a small part of the window

unsigned char* pixels = new unsigned char[ w_ * h_ * 3 ];

glReadPixels( 0 , 0 , w_ , h_ , GL_RGB ,GL_UNSIGNED_BYTE , (GLvoid*) pixels);

thanks Niels

Perhaps your origin is wrong, are you confusing window coords with viewport?

There’s may also a pixel transfer tweak on.

[This message has been edited by dorbie (edited 03-05-2004).]

There’s a distinct possibility that your OS does not allow the frame buffer to be read. This was fixed in later drivers for most systems. Later drivers being ones available about 2 years ago, so I don’t imagine this is the problem.

After a SwapBuffer command the contents of the framebuffer become undefined.

Personally, I would change your array definition to “GLubyte pixels[q_ * h_ * 3];”

new is a C++ operation, and a C++ array may not be the same as a C array. It might be, but I never trust the compiler and run-time of any system. Specifically, the C++ array might be the same as “struct { int length; void* ptr};” and you could be reading garbage in the system memory. Though I don’t know why it wouldn’t just SEGFAULT on you.