converting 2D mouse coordinates to 3D space in OpenGL ES

Posted by Jayesh on Stack Overflow See other posts from Stack Overflow or by Jayesh
Published on 2010-03-28T11:21:31Z Indexed on 2010/03/28 11:23 UTC
Read the original article Hit count: 1039

Filed under:
|

I want to convert mouse's current X and Y coordinates into the 3D space I have drawn in the viewport. I need to do this on the OpenGL ES platform. I found following possible solutions implemented in OpenGL, but none fits what I am looking for.

  1. I found NeHe's tutorial on doing exactly this, but in traditional OpenGL way. It uses gluUnProject. http://nehe.gamedev.net/data/articles/article.asp?article=13 Although gluUnProject is not available in OpenGL ES, its implementation seems simple enough to port back. But before calling it, we need to call glReadPixels with GL_DEPTH_COMPONENT and that is not possible in OpenGL ES. (The reason I found in this thread: http://www.khronos.org/message_boards/viewtopic.php?f=4&t=771)

  2. What I want to do is similar to picking, except that I don't want to select the object but I want exact coordinates so that I can recognize particular portion of the object that is currently under mouse cursor. I went through the Picking tutorials in this answer. http://stackoverflow.com/posts/2211312/revisions But they need glRenderMode, which I believe is absent in OpenGL ES.

If you know how to solve this problem in OpenGL ES, please let me know.

Thanks.

© Stack Overflow or respective owner

Related posts about opengl-es

Related posts about opengl