First, I tried to get the mouse data using GetCursorPos (I only need the position, not the buttons).
Here's the function:
POINT GetMousePos(HWND hWnd)
{
POINT cursorPos;
GetCursorPos(&cursorPos);
ScreenToClient(hWnd, &cursorPos);
return cursorPos;
}
This made a really weird bug in the game.
The mouse position was correct at the top left of the screen, but going down with the mouse creates a gap between the mouse and the given coordinates.
The more I move to the right and bottom, the bigger the gap gets.
For example, when my mouse is at 5,5 it displays 5,5.
When my mouse is at 200,200 it displays 205,210
When my mouse is at 500,500 it displays 510,520
(These is not the data as it displays, but it comes really close)
Note that the Y is growing faster than the X.
After this I tried using the WM_MOUSEMOVE method, but this gave the same result.
I'm only using 1 monitor and the size of the window is 1024x768 (window mode).
I tested all methods on other computers and other mouses, but all give the same results.
I made a texture drawing in the middle of the mouse.
Here are my current codes:
if(message.message == WM_MOUSEMOVE)
{
MousePosition = MAKEPOINTS(message.lParam);
}
position[21].x = MousePosition.x - 16; //Texture width = 32
position[21].y = MousePosition.y - 16; //Texture height = 32
And here's a picture of what happens (The red block is the texture that uses position[21]):
and the only warning I get is:
warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
But I don't think this should be a problem because the other methods aren't giving any warnings and get the same results.
Can someone help me out?