Jump to content
  • Advertisement
Sign in to follow this  
scottrick49

OpenGL glReadPixels draw issue

This topic is 3021 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

I'm working on an Android project and having trouble with glReadPixels. In order to determine what the user is clicking on, I am giving each object a unique color and redrawing the scene. I use glReadPixels to get the pixel color where they touched, and then I'm able to use that color and figure out what object they touched. The (simplified) flow of the draw function looks something like this:
draw()
{
  if (bScreenWasTouched)
  {
    drawSceneWithTouchColors();
    glReadPixels();//read pixel they touched
    glClear(color | depth);
  }

  drawSceneAsUsual();
}
The problem is that on some android devices the screen isn't getting cleared when glClear is called (you can see the results of drawSceneWithTouchColors when I would expect it to be gone). If I remove only the glReadPixels call, then everything works correctly. This really confuses me since I'm still doing all the drawSceneWithTouchColors drawing. At first I thought maybe it was a bug with the device's opengl implementation, but I am seeing this on another phone as well (other phones work fine), which makes me think I'm doing something wrong and most phones are handling my error more gracefully. Any ideas? I'm kinda stumped on this..

Share this post


Link to post
Share on other sites
Advertisement
Sorry I can't help you with your particular glReadPixels problem. But I would suggest you use a ray-triangle test against the world objects instead. That way you don't need to render your scene twice. glReadPixels are known to be slow too, I'd avoid it for that reason alone (I guess reading only a few pixels are quite fast though).

Paul Bourke has some nice information regarding geometry releated problems.

GL

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!