Skip to main content
gamedev.net
🔒 Locked

glReadPixels help

Started by EMBT30 Nov 20, 2008 at 2:09 PM 1 replies 550+ views
Original Post
EMBT30
EMBT30
Hi, I'm trying to build some examples of glReadPixels. But my problem is that I cant't read anything. When I call the function to read from the screen and then try to paint the content again with glDrawPixels (giving glDrawPixels the pointer in which glReadPixels stored the data) in another raster position, I just get a black with gray stripes square. Are there some settings we need to use with this function? I get the same results with glCopyPixels it just don't draw (copy) anything. Can someone help me please? Thanks.
Brother Bob
Brother Bob
If you expect us to help, you need to provide some information. All you're saying is that is doesn't work, and all I can say to that is that you're doing something wrong.
EMBT30
EMBT30
This is the function I was trying. After reading in "pixels" with glReadPixels I send the pointer to glDrawPixels expecting to get the image draw in the new location, but I just get a black and gray square.

void function(void)
{
int width = 127;
int height = 85;

unsigned char* pixels = new unsigned char[width*height*3];

glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(-5, -5, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels);

glRasterPos2i(5, 5);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels);

delete[] pixels;
}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.