Advertisement Jump to content
Sign in to follow this  

opengl es: how to convert from screen coordinates to world coordinates.

This topic is 3833 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 am working with OpenGL | ES, is there are built in function that I can use to transform from screen coordinates to world coordinates? Appreciate any/all help. Regards, MI

Share this post

Link to post
Share on other sites
Normally you would use gluUnproject but obviously the iPhone implementation of OpenGL ES does not have a Glut ported (yet). Since I am also working on an iPhone game and I was curious about your question, I did some research for you. I can make the assumption that you are making an iPhone game based on a similar thread with your username on the iDev games forums :) .

Your best bet at this time would be to look at the MESA CVS and find the gluUnProject implementation and recreate it.

I took the liberty of tracking down the exact file for you but I figure you can look through the code yourself ;) :


My guess is you would need to code the transform_point, invert_matrix, and matmul functions (these names are from memory so they may not be the exact names) as well as the gluUnProject function (with the "other" function that takes depth values if you need such things).

Good luck!

[Edited by - shadowisadog on July 19, 2008 11:31:05 PM]

Share this post

Link to post
Share on other sites
Hi shadowisadog,

:) yup, you caught me ;). thanks for doing the hard work, I'm looking at the file you mentioned. in the mean time however, I have come up with an implementation that more or less solves my problem (I am working in 2D so it was easy). Let me know if you are interested to look at the code and I'll post

(in fact, after looking at the code of project.c, I guess just changing all the doubles to GLfloats should do the trick, However, I don't know what would be the correct way to use the modified code, should I just included it into my project just like any other source?)

thanks again :)


Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!