PDA

View Full Version : glProject and glUnProject only accurate fullscreen



Robbie
12-05-2011, 06:26 AM
I'm having a problem with glProject and glUnproject.

If I'm running my GL instance in a window, not full screen, the point that I draw representing the UnProjected mouse cursor position is offset...it appears to be offset by however much the window is moved from initial instantiation. For example, if I move the window down, the difference increases vertically. Same for if I resize the window.

On initialization, the offset appears to push the drawn vertex down about the same distance as the titlebar is tall, and right about the same distance as the left window border. Odd.

Is there any way to detect this and counter it?

mhagain
12-05-2011, 07:48 AM
Your second problem suggests that you're sizing your window incorrectly on creation. For example, on Windows you should be calling AdjustWindowRect(Ex) to get the client rect size for a given backbuffer size, then feeding the result of that into your CreateWindow(Ex) call.