当前位置: 首页>>代码示例>>C++>>正文


C++ SDL_VideoDevice::CreateWMCursor方法代码示例

本文整理汇总了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);
}
开发者ID:yeKcim,项目名称:warmux,代码行数:56,代码来源:SDL_cursor.c


注:本文中的SDL_VideoDevice::CreateWMCursor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。