Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Moe

using a bitmap as a custom cursor

This topic is 6573 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

Intead of using a regular black and white cursor that I could compile, I decided to use a bitmap instead. What I am trying to do is get the mouse position every frame and blit the bitmap at the cursors position (via Direct Draw blt function). Something is funny. I just can''t get it to work. Here is the code (which is in the main message loop) to get the cursor''s position: case WM_MOUSEMOVE: { //do that neat cursor thingy here //extract mouse position int mouse_x = (int)LOWORD(lparam); int mouse_y = (int)HIWORD(lparam); RECT cursor; DDBLTFX ddbltfx; //set it so that the bitmap is displayed where the cursor should be cursor.top = mouse_y; cursor.left = mouse_x; cursor.bottom = mouse_y + 32; cursor.right = mouse_x + 32; lpddsprimary->Blt(&cursor, lpcursor, NULL, DDBLT_WAIT, &ddbltfx); } break; I can''t figure out what is wrong with it for the life of me. Anyone here have any ideas? Shrapnel Games

Share this post


Link to post
Share on other sites
Advertisement
Not quite sure why you''re passing a DDBLTFX structure to blt
when you aren''t setting any of the parameters in it....how about
passing NULL where you pass the DDBLTFX structure to blt that
might help a little bit.

lpddsprimary->Blt(&cursor, lpcursor, NULL, DDBLT_WAIT, NULL);

~S''Greth

Share this post


Link to post
Share on other sites
Maybe you are flipping the primary surface after you draw the bitmap, so the bitmap is never visible...

VBMaster

Share this post


Link to post
Share on other sites
I see that you have not specified any source rect. But that is probably not the problem. Then the mouse coordinate is relative to the upper-left corner of the client area. You must change this if you are working in window mode.

//set it so that the bitmap is displayed where the cursor should be
cursor.top = g_rcMainWin.top + mouse_y;
cursor.left = g_rcMainWin.left + mouse_x;
cursor.bottom = cursor.top + 32;
cursor.right = cursor.left + 32;

Zeblar Nagrim, Lord of Chaos

Share this post


Link to post
Share on other sites
Your code looks fine. This is just a shot in the dark here. I think your problem may be one of different bit depths. Check the bit depth of your bitmap. Is it the same as your application''s current bit depth?

hope that helped,
skitzo_smurf

Share this post


Link to post
Share on other sites
bit depth shouldnt matter as all surfaces will be the same bitdepth, it maybe you dont have the bitmap loaded correctly in lpcursor

Im Always Bored
--Bordem
ICQ: 76947930

Share this post


Link to post
Share on other sites
sorry,
maybe that wasnt clear enough. I meant that he could be trying to load a 32 bit bitmap onto an 8 bit surface. In other words, I meant to check that the bitmap''s bit depth is the same as his surfaces'' bit depths. That could definitely cause a problem.

skitzo_smurf

Share this post


Link to post
Share on other sites
case WM_MOUSEMOVE:
{
// Store windowrect in global rect
// Do this in your WM_MOVE message,
// not here.
RECT g_rcMainWin;
GetWindowRect(hWnd, &rcClientRect);
CopyRect(&g_rcMainWin, &rcClientRect);

// Hide cursor if inside client rect
int hide;
while(1)
{
hide = ShowCursor(FALSE);
if(hide < 0)
break;
}

//do that neat cursor thingy here
//extract mouse position
int mouse_x = (int)LOWORD(lParam);
int mouse_y = (int)HIWORD(lParam);

// Show cursor on menu
if(mouse_y < 20)
{
while(1)
{
hide = ShowCursor(TRUE);
if(hide > 0)
break;
}
break;
}

RECT cursor;

//set it so that the bitmap is displayed where the cursor should be
cursor.top = g_rcMainWin.top + mouse_y;
cursor.left = g_rcMainWin.left + mouse_x;
cursor.bottom = cursor.top + 32;
cursor.right = cursor.left + 32;

static RECT srect = {0,0,32,32};
lpddsprimary->Blt(&cursor, lpcursor, &srect, 0, &ddbltfx);

}
break;

Zeblar Nagrim, Lord of Chaos

Edited by - Zeblar Nagrim on July 20, 2000 5:59:33 AM

Share this post


Link to post
Share on other sites
well whatever the reason its not showing up since your blting to the primary expect some flicker and tearing of the cursor

Im Always Bored
--Bordem
ICQ: 76947930

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!