PDA

View Full Version : Get the pixels from the OpenGL context.



huangzl99
06-16-2002, 12:31 AM
when I use :
GLFloat* buffer=NULL;

glReadPixels(0, 0, width, height, GL_RGB, GL_FLOAT, buffer );

to get openGL frame, the variable buffer remains NULL. what's wrong with it?

I am using MFC windows to display OpenGL view. the OpenGL viewport is set larger than the window size.

please help me

Robbo
06-16-2002, 12:56 AM
Originally posted by huangzl99:
when I use :
GLFloat* buffer=NULL;

glReadPixels(0, 0, width, height, GL_RGB, GL_FLOAT, buffer );

to get openGL frame, the variable buffer remains NULL. what's wrong with it?

I am using MFC windows to display OpenGL view. the OpenGL viewport is set larger than the window size.

please help me


Try this:

GLFloat buffer[WIDTH*HEIGHT*3];

glReadPixels(0, 0, width, height, GL_RGB, GL_FLOAT, buffer );


glReadPixels will ignore the entire command because the buffer you passed in is NULL. You need to pass in a pointer to a block of memory within which to place the pixel data.

I've never used glReadPixels, so the above might not quite be right -