Skip to main content
GameDev.net gamedev.net
🔒 Locked

directdraw and mouse pointer

Started by meynaf Nov 26, 2001 at 8:17 AM 5 replies 1.9k views
Original Post
meynaf
meynaf
Hi, I have a DirectDraw application, which must work either in fullscreen or windowed (switch via alt-enter). Sometimes the mouse pointer flickers or leaves a trail under it (happens in both windowed and fullscreen, and this depends of the machine). And this only happens on some gfx boards, not all. On mine, it works perfectly. Shouldn''t directx be hiding the hardware differencies ? It obviously doesn''t I can''t handle the mouse via DirectInput and draw it manually because of the windowed mode, so I''m forced to let Windows handle the mouse. I can''t believe nobody had this problem before. Help me please !!!
thedo
thedo
Do you actually need to see the mouse pointer?
if NO then
ShowCursor(False);

if yes the why not :-

int x,y; //xand y mouse coords
ShowCursor(False); //Hide the ''proper cursor''
GetMouseXY(&x,&y); //Get the mouse cursor position
DrawDirectDrawSprite(x,y); //Draw a DirectDraw sprite as cursor

Neil
WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!
meynaf
meynaf
Of course I need to see it, the game is mouse based !!
And I can''t replace the mouse pointer by a sprite, because the pointer can go outside my window in windowed mode.
thedo
thedo
OK Check to see if the mouse is in the Directdraw window and write the above code. When not in the window show the ''Windows'' cursor. Unfortunately there''s not much else you can do. It''s not a DirectX thang, it''s a bad driver thang.

Neil
WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!
Kwizatz
Kwizatz
thedo is right, use GetWindowRect to get the window position and proportions, then you do something like (using thedo's code):

  
HWND hWnd; //this is a global variable that contains the main window handle

int x,y; //xand y mouse coords

RECT rect;

GetMouseXY(&x,&y); //Get the mouse cursor position

GetWindowRect(hWnd,▭)
if ((x<rect.left)||(x>rect.right)||(y<rect.top)||(y>rect.bottom)) //boundary check if this is true use windows cursor

{
ShowCursor(true); //Show the 'proper cursor'

}
else // we are inside the window draw a ddraw cursor

{
ShowCursor(false); //Hide the 'proper cursor'

DrawDirectDrawSprite(x,y); //Draw a DirectDraw sprite as cursor

}


and thats pretty much it, you might want to use GetCursorPos



Edited by - kwizatz on November 26, 2001 11:18:42 AM
meynaf
meynaf
Ok I''ll test this... but I fear a lack of responsiveness from the mouse pointer, because the program''s refresh rate is not quite high
Kwizatz
Kwizatz
now that I think about it, you can check whether the cursor is shown or not

  
HWND hWnd; //this is a global variable that contains the main window handle

BOOL bWinCursor = TRUE; //Global variable to keep track

int x,y; //xand y mouse coords

RECT rect;
GetMouseXY(&x,&y); //Get the mouse cursor position

GetWindowRect(hWnd,▭)
if ((x<rect.left)||(x>rect.right)||(y<rect.top)||(y>rect.bottom)) //boundary check if this is true use windows cursor

{
if(!bWinCursor)
{
bWinCursor=TRUE;
ShowCursor(bWinCursor); //Show the ''proper cursor''

}
}
else // we are inside the window draw a ddraw cursor

{
if(bWinCursor)
{
bWinCursor=FALSE;
ShowCursor(bWinCursor); //Hide the ''proper cursor''

}
DrawDirectDrawSprite(x,y); //Draw a DirectDraw sprite as cursor

}


its getting complicated, I just coded that, so its not tested, you have been warned
anyway is just so you get an idea

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.