Good night.
I’m been spending all evening searching for the solution to my problem, and I’ve looked through three dozen threads on these forums but I haven’t been able to find any solution. This makes me believe my problem might be much more trivial than I would suspect.
Here’s the deal. I’m using a simple quad translated to -50 units down the z axis, 10 units high and 10 across. Using the normal glReadPixels/glUnProject method I get pretty weird results. Clicking in say the lower left corner of the quad gives these world coordinates:
(-0.0097028091709283129, -0.0095295440940463359, 49.899608630543526)
the z-value seems to match the 50 I translated when drawing the quad, the offset is probably my depth range, 0.1 to 100. The other values would be correct, if the quad would have been translated to z = 0. It seems I’m getting some kind of mapping with glUnProject, but it is not using any type of depth algorithm for the screen position and z-value. glReadPixels gives a depth value of 0.00390233960934, which looks alright to the untrained eye.
Since I am an opengl newbie I’m not really sure what could be wrong. Am I missing some matrix operations I should be aware of? This example is as basic as it gets, and I’ve tried adapting to several other solutions presented in these forums but I just can’t get it to work. Any help would be great!
Oh, and any basic full-program source examples are most welcome.