本文整理汇总了C++中SDL_VideoDevice::ShowWMCursor方法的典型用法代码示例。如果您正苦于以下问题:C++ SDL_VideoDevice::ShowWMCursor方法的具体用法?C++ SDL_VideoDevice::ShowWMCursor怎么用?C++ SDL_VideoDevice::ShowWMCursor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SDL_VideoDevice
的用法示例。
在下文中一共展示了SDL_VideoDevice::ShowWMCursor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SDL_SetCursor
/* SDL_SetCursor(NULL) can be used to force the cursor redraw,
if this is desired for any reason. This is used when setting
the video mode and when the SDL window gains the mouse focus.
*/
void SDL_SetCursor (SDL_Cursor *cursor)
{
SDL_VideoDevice *video = current_video;
SDL_VideoDevice *this = current_video;
/* Make sure that the video subsystem has been initialized */
if ( ! video ) {
return;
}
/* Prevent the event thread from moving the mouse */
SDL_LockCursor();
/* Set the new cursor */
if ( cursor && (cursor != SDL_cursor) ) {
/* Erase the current mouse position */
if ( SHOULD_DRAWCURSOR(SDL_cursorstate) ) {
SDL_EraseCursor(SDL_VideoSurface);
} else if ( video->MoveWMCursor ) {
/* If the video driver is moving the cursor directly,
it needs to hide the old cursor before (possibly)
showing the new one. (But don't erase NULL cursor)
*/
if ( SDL_cursor ) {
video->ShowWMCursor(this, NULL);
}
}
SDL_cursor = cursor;
}
/* Draw the new mouse cursor */
if ( SDL_cursor && (SDL_cursorstate&CURSOR_VISIBLE) ) {
/* Use window manager cursor if possible */
if ( SDL_cursor->wm_cursor &&
video->ShowWMCursor(this, SDL_cursor->wm_cursor) )
SDL_cursorstate &= ~CURSOR_USINGSW;
else {
SDL_cursorstate |= CURSOR_USINGSW;
if ( video->ShowWMCursor ) {
video->ShowWMCursor(this, NULL);
}
{ int x, y;
SDL_GetMouseState(&x, &y);
SDL_cursor->area.x = (x - SDL_cursor->hot_x);
SDL_cursor->area.y = (y - SDL_cursor->hot_y);
}
SDL_DrawCursor(SDL_VideoSurface);
}
} else {
/* Erase window manager mouse (cursor not visible) */
if ( SDL_cursor && (SDL_cursorstate & CURSOR_USINGSW) ) {
SDL_EraseCursor(SDL_VideoSurface);
} else {
if ( video ) {
video->ShowWMCursor(this, NULL);
}
}
}
SDL_UnlockCursor();
}