PDA

View Full Version : glReadPixels reads mass value



huangzl99
06-16-2002, 08:07 AM
when I use the following code:

GLfloat* buffer=NULL;
buffer= new GLfloat[width*height*3];
glReadPixels(0, 0, width, height, GL_RGB, GL_FLOAT, buffer );

I found buffer[0], buffer[1], buffer[2] gives mass value.(4.01e008 something).

what's wrong with it? I used MFC windows for openGL display.

Jerry

zeckensack
06-16-2002, 08:28 AM
Assuming
1)You have a valid GL context and it's made current (insert wglMakeCurrent(blabla) to be sure)
2)You already did some drawing (eg at least one glClear)

that might be a driver bug. What gfx card do you use, maybe someone else can verify this? http://www.opengl.org/discussion_boards/ubb/smile.gif

edit:
Assumption 3)Your width/height aren't out of bounds.

[This message has been edited by zeckensack (edited 06-16-2002).]

Jambolo
06-16-2002, 09:44 AM
The code you supplied looks right (according to the specs). Maybe you need to call glReadBuffer.