EMBT30
11-20-2008, 03:31 PM
Hi. Iīm trying to create some examples of glReadPixels and glCopyPixels but Iīm having some problems.
After rendering a scene I use glReadPixels to read a section of the screen and then I pass that pointer to glDrawPixels so I can draw it in a new rastre location. The thing is that it only draws a black square with two gray lines. Also glCopyPixels doesīt draw any thing when I try to use it.
I donīt know if it is some driver problem or what am I doing wrong.
Here are the functions:
void Read(void)
{
int w = 127;
int h = 85;
GLubyte* pixels = new GLubyte[w * h * 3]);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(-5, -5, w, h, GL_RGB, GL_UNSIGNED_BYTE, pixels);
glRasterPos2i(0, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glDrawPixels(w, h, GL_RGB, GL_UNSIGNED_BYTE, pixels);
delete[] pixels;
}
void Copy(void)
{
glRasterPos2i(5, 5);
glCopyPixels(-5, -5, 127, 85, GL_COLOR);
}
Please help.
Thanks.
After rendering a scene I use glReadPixels to read a section of the screen and then I pass that pointer to glDrawPixels so I can draw it in a new rastre location. The thing is that it only draws a black square with two gray lines. Also glCopyPixels doesīt draw any thing when I try to use it.
I donīt know if it is some driver problem or what am I doing wrong.
Here are the functions:
void Read(void)
{
int w = 127;
int h = 85;
GLubyte* pixels = new GLubyte[w * h * 3]);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(-5, -5, w, h, GL_RGB, GL_UNSIGNED_BYTE, pixels);
glRasterPos2i(0, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glDrawPixels(w, h, GL_RGB, GL_UNSIGNED_BYTE, pixels);
delete[] pixels;
}
void Copy(void)
{
glRasterPos2i(5, 5);
glCopyPixels(-5, -5, 127, 85, GL_COLOR);
}
Please help.
Thanks.