Jump to content
  • Advertisement
Sign in to follow this  
EMBT30

glReadPixels help

This topic is 3624 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!