PDA

View Full Version : glReadPixels doesn't work anymore



hannes-fassold
09-05-2002, 01:45 AM
Hi !

I want to save the screen content - what already worked. but now i added some other things and now i have the following problem:

when i call "glReadPixels" to get the content of the framebuffer, it does NOTHING.
It generates no error, but doesn't read anything in the array.

My application is single-buffered, and glReadPixels reads from the default color buffer (GL_FRONT_LEFT).

i have absolutely no idea because it doesn't worke anymore

bye,

Hannes

vincoof
09-05-2002, 01:55 AM
Would you please write the line where you call glReadPixels ?

Also, what OS/graphics card/driver do you have ?

hannes-fassold
09-05-2002, 03:48 AM
The lines:
// window_x_, window_y_ ... size of (glut-created) window
GLubyte* img_buf = new GLubyte [3 * window_x_ * window_y_];
glReadPixels (0, 0, window_x_, window_y_, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*) img_buf);

I use Windows 98. Graphic-Card: ATI Rage Mobility. I link against Opengl32, glu32, glut32 - libraries (i think these are the one from SGI).
I had to turn "hardware accelerating" off because otherwise the os crashed periodly when i debugged my opengl-program.

The strang thing is that 'glReadPixels' already worked fine. Then i added some features to my program and now glReadPixels does nothing.

vincoof
09-05-2002, 04:34 AM
Two things :
- please call glGetString(GL_VENDOR), glGetString(GL_RENDERER) and glGetString(GL_VERSION) and post here the results. Because turning hardware acceleration to off may switch your engine to software rendering (and those calls will show that),
- now that you added a few lines of code, do you call glPixelStore, glPixelTransfer or glPixelMap ?

hannes-fassold
09-05-2002, 04:47 AM
hi !

glReadPixels did work also after i turned off the hardware acceleration.

The Output from the glGets() is:

Microsoft Corporation
GDI Generic
1.1.0

My PixelStore-Commands are:
(I dont know if i need all of them)

glPixelStorei(GL_PACK_ALIGNMENT,1);
glPixelStorei( GL_PACK_ROW_LENGTH, window_x_ );
glPixelStorei( GL_PACK_SKIP_ROWS, 0 );
glPixelStorei( GL_PACK_SKIP_PIXELS, 0 );
glPixelStorei( GL_PACK_ALIGNMENT, 1 );

glPixelStorei( GL_PACK_SKIP_ROWS, 0 );
glPixelStorei( GL_PACK_SKIP_PIXELS, 0 );
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );

I have no glPixelMap - Commands in the program

vincoof
09-05-2002, 05:22 AM
The Output from the glGets() is:

Microsoft Corporation
GDI Generic
1.1.0
you're running the software renderer. Expect bad performance.

Did you add some of those glPixelStore commands between the time glReadPixels worked and between the time glReadPixels did not work ?


I have no glPixelMap - Commands in the program
I'm assuming you don't call glPixelTransfer either, right ?

hannes-fassold
09-05-2002, 05:26 AM
you are right.

NO glPixelTransfer - commands.

vincoof
09-05-2002, 05:43 AM
Also, what do you mean by "it does NOTHING" ? Does your buffer remains unchanged ? Is it filled by zeros only ? Are the colors messed up ?

hannes-fassold
09-05-2002, 05:46 AM
it doesn't change the buffer content.

in fact, i can pass a NULL-pointer to glReadPixels and it doesn't complain.

vincoof
09-05-2002, 05:55 AM
OpenGL specifies that if an error is generated, the buffer is not modified.
Have you called glGetError() just after glReadPixels ?

hannes-fassold
09-05-2002, 06:15 AM
of course i call glGetError after.
it reports no error.

V-man
09-05-2002, 07:33 AM
You could try a few things:

try GL_RGBA instead of RGB
try calling glFinish() right after ReadPixels
make sure the width and height parameter are positive

otherwise, it probably is just buggy drivers. That card is pretty much obsolete and is no longer supported.

V-man

hannes-fassold
09-05-2002, 08:01 AM
now it works !

i turned the hardware acceleration on - now i can read the pixels.

it seems to be a problem of the software rendering / driver.

thanks for the helpful comments,

Hannes