SDL,改变光标



我正在使用SDL库,但是我试图加载*.bmp文件并将其显示为我的新光标,而不是黑白光标。

我认为,我最检查鼠标的位置并在循环中绘制SDL_Surface在该位置,

我的代码:

//Declare SDL_Surface pointers
SDL_Surface *cursor;
SDL_Surface *image;
SDL_ShowCursor( SDL_DISABLE ); //Standard cursor must be turned off
image = SDL_LoadBMP("mouse.bmp"); //Load my cursor
cursor = SDL_DisplayFormat(image); //Set
//Set the color as transparent
SDL_SetColorKey(cursor,SDL_SRCCOLORKEY|SDL_RLEACCEL,SDL_MapRGB(cursor->format,0x0,0x0,0x0));

创建并设置一个新的SDL_Cursor应该可以工作。

SDL_Surface *surface = IMG_Load(filename);
SDL_Cursor *cursor = SDL_CreateColorCursor(surface);
SDL_SetCursor(cursor);

最新更新