Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

MrWendell1982

glReadPixels

This topic is 5271 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 all, I am trying to read the frame buffer on each call to my rendering function. I use the following line of code: glReadBuffer(GL_BACK); glReadPixels(0, 0, 500, 500, GL_RGB, GL_INT, &pBits); However, as soon as the call to glReadPixels is reached the program terminates. Can anyone suggest why or what i am doing wrong. I have included the code at the end. Thanks void display(void) { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); setCam(); displayGrid(); glFlush(); glutSwapBuffers(); //read the pixels from the buffer printf("Reading Pixel Values...\n"); glReadBuffer(GL_BACK); glReadPixels(0, 0, 500, 500, GL_RGB, GL_INT, &pBits); }

Share this post


Link to post
Share on other sites
Advertisement
The last parameter of glReadPixels requires a pointer. It looks as if you are passing it a pointer to a pointer.

If pBits is already a pointer try removing the ''&''.

- CheeseMonger

Share this post


Link to post
Share on other sites
And why are you reading from the back buffer directly after a buffer swap? When swapping the buffers, the image is in the front buffer, the content of the back buffer at that point is undefined.

Share this post


Link to post
Share on other sites

  • 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!