Jump to content
  • Advertisement
Sign in to follow this  
DarkZoulz

d3d mouse cursor woes...

This topic is 4820 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to replace the windows mouse cursor with my own using the DX functions SetCursorProperties() and ShowCursor(). It seems to be working quite well in windowed mode (expect I keep getting the WM_SETCURSOR windows message over and over). In fullscreen mode however the mouse cursor is greatly scaled (bloated) and I can't move it. Very odd. I want my game to be able to run in both windowed and fullscreen mode. Also, how do they figure that I retrieve the mouse position? using API function GetCursorPos() in WM_MOUSEMOVE?

Share this post


Link to post
Share on other sites
Advertisement
I would look into using the Direct Input library. I know from expereince that it is fairly eeasy to get the cursor position. I am slao pretty sure that somewhere it is possible to make the cursor invisible.

Sorry, can't say much else.

ace

Share this post


Link to post
Share on other sites
Quote:
Original post by DarkZoulz
I'm trying to replace the windows mouse cursor with my own using the DX functions SetCursorProperties() and ShowCursor(). It seems to be working quite well in windowed mode (expect I keep getting the WM_SETCURSOR windows message over and over). In fullscreen mode however the mouse cursor is greatly scaled (bloated) and I can't move it. Very odd. I want my game to be able to run in both windowed and fullscreen mode.

Also, how do they figure that I retrieve the mouse position? using API function GetCursorPos() in WM_MOUSEMOVE?

1) Windows always sends WM_SETCURSOR over and over. I've never been able to understand what the point in that is though.
2) Any chance of a screenshot or code sample? When you say the cursor is bloated, are you sure it's not because the resolution is lower in fullscreen mode? (e.g. 640x480 vs 1280x1024)
3) Yes, you should use either GetCursorPos() or WM_MOUSEMOVE to get the cursor position. For something like a mouse cursor, I'd advise using WM_MOUSEMOVE and getting the cursor position from the lParam (Since it'll me marginally faster than using GetCursorPos())

Share this post


Link to post
Share on other sites
it's easier to just use D3DXSPRITE and draw a mouse cursor with DirectInput. But i'd really like to use the hardware cursor...

http://www.herobash.com/screen.jpg
this is what I mean't by bloated cursor... it's 800x600.

Share this post


Link to post
Share on other sites
Hmm... I've no idea. What size is the surface that you're setting as the cursor? It looks like its 32x32 scaled to 128x128 in the fullscreen version.
The DX9 docs imply that only 32x32 cursors are fully supported in hardware.

Share this post


Link to post
Share on other sites
It's 32x32 A8R8G8B8. The wierd thing is that it works nicly in windowed mode.



LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_CLOSE:
g_isRunning = false;
break;

case WM_DESTROY:
g_isRunning = false;
break;

case WM_SETCURSOR:
SetCursor(NULL);
g_pMainGame->m_pFrostEngine->Set_Mouse_Cursor(); // This calls device->ShowCursor()
return TRUE;
break;

case WM_MOUSEMOVE:
GetCursorPos(&g_pMainGame->m_mousePos);
break;

default:
return DefWindowProc(hWnd, message, wParam, lParam);
}

return 0;
}




I use SetCursorProperties() during the D3D initialization to set the new mouse cursor. This is done before the app is trapped in the main game loop which also processes windows messages.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!