本文整理汇总了C++中SDL_VideoDevice::CreateWMCursor方法的典型用法代码示例。如果您正苦于以下问题:C++ SDL_VideoDevice::CreateWMCursor方法的具体用法?C++ SDL_VideoDevice::CreateWMCursor怎么用?C++ SDL_VideoDevice::CreateWMCursor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SDL_VideoDevice
的用法示例。
在下文中一共展示了SDL_VideoDevice::CreateWMCursor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
/* Software cursor drawing support */
SDL_Cursor * SDL_CreateCursor (Uint8 *data, Uint8 *mask,
int w, int h, int hot_x, int hot_y)
{
SDL_VideoDevice *video = current_video;
int savelen;
int i;
SDL_Cursor *cursor;
/* Make sure the width is a multiple of 8 */
w = ((w+7)&~7);
/* Sanity check the hot spot */
if ( (hot_x < 0) || (hot_y < 0) || (hot_x >= w) || (hot_y >= h) ) {
SDL_SetError("Cursor hot spot doesn't lie within cursor");
return(NULL);
}
/* Allocate memory for the cursor */
cursor = (SDL_Cursor *)SDL_malloc(sizeof *cursor);
if ( cursor == NULL ) {
SDL_OutOfMemory();
return(NULL);
}
savelen = (w*4)*h;
cursor->area.x = 0;
cursor->area.y = 0;
cursor->area.w = w;
cursor->area.h = h;
cursor->hot_x = hot_x;
cursor->hot_y = hot_y;
cursor->data = (Uint8 *)SDL_malloc((w/8)*h*2);
cursor->mask = cursor->data+((w/8)*h);
cursor->save[0] = (Uint8 *)SDL_malloc(savelen*2);
cursor->save[1] = cursor->save[0] + savelen;
cursor->wm_cursor = NULL;
if ( ! cursor->data || ! cursor->save[0] ) {
SDL_FreeCursor(cursor);
SDL_OutOfMemory();
return(NULL);
}
for ( i=((w/8)*h)-1; i>=0; --i ) {
cursor->data[i] = data[i];
cursor->mask[i] = mask[i] | data[i];
}
SDL_memset(cursor->save[0], 0, savelen*2);
/* If the window manager gives us a good cursor, we're done! */
if ( video->CreateWMCursor ) {
cursor->wm_cursor = video->CreateWMCursor(video, data, mask,
w, h, hot_x, hot_y);
} else {
cursor->wm_cursor = NULL;
}
return(cursor);
}