Sign in to follow this  
Quinnie

Game Resolution And Mouse Coords

Recommended Posts

Quinnie    163
Hey everyone, i'm having, a hopefully simple, problem with DirectX and the Coördinates of the mouse cursor. I would like to set the screen resolution to 800x600. This is my CreateWindow function:
hWnd = CreateWindowEx( WS_EX_APPWINDOW, "Program1", "Program 1", WS_POPUP, 0, 0,
                       GetSystemMetrics(SM_CXSCREEN),
                       GetSystemMetrics(SM_CYSCREEN),
                       NULL, NULL, GetModuleHandle(NULL), NULL ); 

And here my backbuffer settings: (Not sure if they are important anyway)
d3dpp.BackBufferWidth			= 800;
d3dpp.BackBufferHeight			= 600;

This is the code where I set my cursor
g_pd3dDevice->SetCursorProperties(0, 0, g_pMouseSurface)

This is the code I use to retreive the current mouse coordinates
g_lpMouse->GetDeviceState( sizeof(DIMOUSESTATE2), &MouseState )

Now when I check de coordinates the GetDeviceState function gets they don't match the range of [0,800] and [0,600] instead they seem to use my default computer resolution settings. If I change my CreateWindow settings to use 800x600 the application wont run fullscreen and instead just uses a part of the entire screen. Any help is appreciated, Thanks in Advance...

Share this post


Link to post
Share on other sites
Xai    1838
non DirectX apps do not normally affect the resolution (I've never done this or seen it done ... a windows desktop app is suppsoed to live on the desktop in any size screen the user wants) ... but in directx apps ...

iDirectDraw->SetCooperativeLevel(hwnd,DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN);
iDirectDraw->SetDisplayMode(800,600,16); // the 16 is color depth which is probably not the best default choice ... but ...

here's 1 link of many

http://www.mvps.org/user32/directxtutorial.html

Share this post


Link to post
Share on other sites
xycsoscyx    1149
The values returned inside DIMOUSESTATE2 are actually relative offsets in the devices local system. The values are all relative to the current sensitivity of the device itself, not your resolution. You need to scale this yourself appropriately (basically adding your own sensitivity), if it's too much then divide it, too little then multiply it. I don't know if DirectInput really has any way to read the current sensitivity of the device, though (it's a Windows settings AFAIK), so how much you want to scale it is up to you (trial and error to find a smooth value, or make it configurable). Keep in mind that different machines will have different sensitivity values.

Share this post


Link to post
Share on other sites
Quinnie    163
Thanks a lot,

i'll look into it this afternoon. Just to clearify, there is no directinput function to retreive the mouse coordinates in absolute value?

Thanks again :P

Share this post


Link to post
Share on other sites
Endurion    5407
AFAIK you can set the dinput device properties to get absolute coordinates instead of relative, but...

If you use the mouse for GUI-like things you're way better off to do that with the Win32 mouse messages. They'll take in account all the user settings which you'd have to do yourself.

Share this post


Link to post
Share on other sites
Quinnie    163
I'm actually using it for in-game rotation and movement as well as for a in-game gui with some windows etc.

They annoying part is that the coords on wich my 2D images are renderd are really strange (All really small negative numbers I think), this is likely because of the projection settings etc.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this