• Advertisement
Sign in to follow this  

Problems using a custom mouse cursor.

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

Hi everyone! Im trying to use my custom mouse cursor by loading it from a .bmp image. In my game I have a render() function which is called almost like a while loop, so inside, I inserte the following code: int xm, ym; SDL_GetMouseState(&xm, &ym); rect = (SDL_Rect) {xm-16,ym-16, 0,0}; SDL_BlitSurface(cursor, NULL, surface, &rect); SDL_GL_SwapBuffers(); glFlush(); And in the Init() function I have this: SDL_ShowCursor(SDL_DISABLE); image = SDL_LoadBMP("cursor.bmp"); //Load my cursor cursor = SDL_DisplayFormat(image); //Set if (cursor == NULL) { SDL_Quit(); } Uint32 color; color = SDL_MapRGB(cursor->format, 0,0,0); SDL_SetColorKey(cursor, SDL_SRCCOLORKEY | SDL_RLEACCEL, color); When I execute the program the mouse cursor doesnt appear, so I dont know that Im doing wrong... Id like to know anyway to do it, whatever it is SDL or OPENGL... Thanks in advance...

Share this post


Link to post
Share on other sites
Advertisement
I'm not very familiar with SDL, but have you tried:


rect = (SDL_Rect) {xm,ym, 16, 16};


It's very likely that the width and height must be normalized (greater than 0).

EDIT: Just to clearify a bit:
SDL_Rect takes four parameters; x-coord, y-coord, width and height.
The parameters xm-16, ym-16, 0,0 essentialy sets up a rectangle at x = xm-16, y = ym-16 with width = 0 and height = 0, which won't do much since the image becomes (in practice) infinitly small.

If you, for some reason, were trying to offset the cursor with (-16,-16), the correct way of doing this would be:

rect = (SDL_Rect) {xm - 16, ym - 16, 16, 16};


[Edited by - cmv on November 11, 2008 8:07:12 AM]

Share this post


Link to post
Share on other sites
I tried that, but that wasnt the problem. I think that the problem comes from trying to paint on the screen using SDL while I am using OpenGL for drawing the scene... Ill try to look for some tutorials where I can get that explained.

If anyone knows how Ill still come for a reply.

Thanks

Share this post


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

  • Advertisement