PDA

View Full Version : glReadPixels/gluUnProject/cocoa



nib
04-25-2008, 10:54 AM
In my old Carbon full screen implementation, my chunk of code worked fine. That is, the origin is the lower left of the viewable area for unproject. With glReadPixels, I would read from depth into a single float. I read my matrix information from openGL's state.

Now, in cocoa I get a 0 or 1 from the depth read.

Maybe my mouse coordinate is not what the system is expecting. (?)

OneSadCookie
04-27-2008, 02:15 AM
Mouse coordinates in Carbon are from the upper left of the window; in Cocoa, from the lower left. Perhaps that is confusing the issue?

nib
05-15-2008, 10:04 PM
I got the mouse coordinates mapped for cocoa and the change fixed the problem.

Had another pilot error. In my program, if there is an alpha channel present in the texture, the program automatically turns on blending and turns off depth and culling. So, I would get unexpected depth values from glReadPixels when clicking on the ground. Removed the unneeded alpha channel and it worked.

Meanwhile, there is a pile of pulled out hair next to my chair. :)