PDA

View Full Version : high res mouse coordinates



Apoptyzm
09-19-2009, 05:05 AM
Hi,
im working on 2d shooter in c++ and my mouse cursor jumps from point to point instead of moving fluently.
It's not a problem when camera is still and im just moving mouse but it is irritating when player/camera moves and i move cursor in the same time - it just jump those small steps.

I know that it's because i get mouse points as int's and i can't find a method to get them in float or real...

So GetCursorPos() and LOWORD/HIWORD sux. Only thing i can think of to get it over is lowering mouse sensitivity in game by dividing those int points by something.

Are there any other methods in OGL?

THX for any suggestions ;*

scratt
09-19-2009, 05:16 AM
You don't "get" your mouse pointer position from OpenGL, you get it from some other API (perhaps your system APIs, or even something like SDL).

In your case it looks like this http://msdn.microsoft.com/en-us/library/ms648390(VS.85).aspx
But this is mapped one to one with the screen resolution so should give you mouse coordinates in pixel point accuracy AFAIK.

What I suspect your problem is, is how you are converting those values to make your camera matrix.

Something like this might help you..
http://sharktooth.org/tutorials/software/visual_c/step6.html

Apoptyzm
09-19-2009, 07:02 AM
Yes, im using winapi to get mouse point and glUnProject to map it to openGl point.
It's not glUnProject fault.

Is there a way to get mouse position in higher precision in/FROM OpenGL(not GLUT)?

I dont want to incude DirectX or some other heavy libs to get this.

Ilian Dinev
09-19-2009, 07:07 AM
OpenGL is just this: a graphics library. All your mouse-funcs are belong to OS.
Do use DirectInput. You don't need to include anything heavy like D3DX.