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

Started by
1 comment, last by Ishaq 15 years, 9 months ago
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
Advertisement
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 ;) :

Project.c

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]
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 :)

Regards,
MI

This topic is closed to new replies.

Advertisement