• Advertisement
Sign in to follow this  

Get real world coords with DirectInput

This topic is 2685 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 was wondering if there is a way to get the actual world coordinates of a DirectX window. Below was my original idea... but the coordinates will still start out where the mouse position originally started, and if you move out of the application window the coordinates still change. I wanted something more along the lines of how in GDI you can use WM_MOUSEMOVE to detect when the mouse is moving and then get the actual coords inside of the window, and output them to the screen.


//========================================================================
//get mouse coords to print to screen
//========================================================================
xcord += (float)mouse_state.lX;
ycord += (float)mouse_state.lY;

if (xcord < 0)
xcord = 0;
if (ycord < 0)
ycord = 0;

if (xcord > G_width)
xcord = G_width;
if (ycord > G_height)
ycord = G_height;

sprintf_s(xBuffer, 20, "X: %f", xcord);
sprintf_s(yBuffer, 20, "Y: %f", ycord);

D3DXCreateText(device, G_hdc, xBuffer, 300.0f, 0.004f, &Text_mesh, 0, 0);
D3DXCreateText(device, G_hdc, yBuffer, 300.0f, 0.004f, &Text_mesh2, 0, 0);
//========================================================================


Share this post


Link to post
Share on other sites
Advertisement
If you need sensual mouse coordinates don't use DirectInput. Seriously use WM_MOUSEMOVE. The window messages take all kind of user settings into account, while DirectInput does not.

Even if you keep your own set of current mouse position it will feel weird to the user, since all special behaviour is not active.

Share this post


Link to post
Share on other sites
thanks, i ended up taking your advice and just using WM_MOUSEMOVE to handle my coordinates.

Share this post


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

  • Advertisement