Witam. Próbowałem zamienić standardowy kursor na bitmapę, jednak po zamianie bitmapa nie nadąża za zwykłym kursorem (zacina się) co można łatwo zauważyć dodając do kodu SDL_ShowCursor (wtedy widać i bitmapę i standardowy kursor). Wie ktoś jak na to zaradzić ??? A może istnieje jakiś inny sposób na zamianę kursora na bitmapę w SDL ???
#include <SDL/SDL.h>
int mousex, mousey;
SDL_Surface* init_sdl(int width, int height)
{
SDL_Init(SDL_INIT_VIDEO);
return SDL_SetVideoMode(width, height, 0, SDL_HWSURFACE | SDL_DOUBLEBUF |SDL_FULLSCREEN);
}
void exit_sdl(SDL_Surface* surface)
{
SDL_FreeSurface(surface);
SDL_Quit();
}
int events()
{
SDL_Event event;
while(SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_MOUSEMOTION:
mousex = event.motion.x;
mousey = event.motion.y;
break;
case SDL_QUIT: return 0;
}
}
return 1;
}
int main( int argc, char* args[] )
{
SDL_Surface *surf = init_sdl(1280, 1024);
SDL_Surface *curs = SDL_LoadBMP("temp.bmp");
SDL_ShowCursor(0);
SDL_Rect dst;
dst.w = curs->w;
dst.h = curs->h;
while(events())
{
SDL_FillRect(surf, NULL, SDL_MapRGB(surf->format, 0, 0, 0));
dst.x = mousex;
dst.y = mousey;
SDL_BlitSurface(curs, NULL, surf, &dst);
SDL_Flip(surf);
}
exit_sdl(surf);
}