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


C++ SDL_SetCursor函数代码示例

本文整理汇总了C++中SDL_SetCursor函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_SetCursor函数的具体用法?C++ SDL_SetCursor怎么用?C++ SDL_SetCursor使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SDL_SetCursor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SDL_SetCursor

void SDLMouse::setCursor( MouseCursor* mc )
{
	pCursor = (SDLMouseCursor*)mc;

	if ( pCursor != NULL ) {
		if ( pCursor->isSystem() ) {
			SDL_SetCursor( pCursor->getSDLCursorObject() );
		} else {
		}
	}

}
开发者ID:dcthe1,项目名称:GameUI,代码行数:12,代码来源:uisdlmouse.cpp

示例2: sdl_hide_cursor

static void sdl_hide_cursor(void)
{
    if (!cursor_hide)
        return;

    if (kbd_mouse_is_absolute()) {
        SDL_ShowCursor(1);
        SDL_SetCursor(sdl_cursor_hidden);
    } else {
        SDL_ShowCursor(0);
    }
}
开发者ID:EgoIncarnate,项目名称:qemu-rr,代码行数:12,代码来源:sdl.c

示例3: SDL_GetMouseState

bool Game::MouseDragReset(Entity *object)
{
    //Cursor on Hover

    if(dragOne == true && object->draggable == false)
        return false;

    int mouseX = 0;
    int mouseY = 0;

    SDL_GetMouseState(&mouseX, &mouseY);

    if(object->Hover(mouseX, mouseY) == true)
    {
        SDL_SetCursor(Cursor);

        if(LeftButtonPressed == true)
            object->draggable = true;
    }

    if(LeftButtonPressed == false)
        object->draggable = false;

    if(object->draggable == true)
    {
        object->XPos = mouseX - object->Width / 2;
        object->YPos = mouseY - object->Height / 2;
        SDL_SetCursor(DragCursor);
        dragOne = true;
        return true;
    }
    else
    {
        dragOne = false;
        object->XPos = object->defaultX;
        object->YPos = object->defaultY;
        return false;
    }

}
开发者ID:ASDF-UNICORNS,项目名称:Tree-Hack,代码行数:40,代码来源:OnLoop.cpp

示例4: SDL_FreeCursor

//------------------------------------------------------------------------------------------------------
//setter function that creates a system mouse cursor 
//------------------------------------------------------------------------------------------------------
void InputManager::SetMouseCursorType(CursorType cursorType)
{

	//first destroy old cursor object from memory
	SDL_FreeCursor(m_cursor);

	//based on type of cursor value passed, create mouse cursor using SDL ID flag value 
	m_cursor = SDL_CreateSystemCursor(SDL_SystemCursor(cursorType));
	
	//use cursor pointer to assign cursor to SDL
	SDL_SetCursor(m_cursor);

}
开发者ID:djkarstenv,项目名称:Handmade,代码行数:16,代码来源:InputManager.cpp

示例5: sdl_grab_start

static void sdl_grab_start(void)
{
    if (guest_cursor) {
        SDL_SetCursor(guest_sprite);
        SDL_WarpMouse(guest_x, guest_y);
    } else
        sdl_hide_cursor();
    SDL_WM_GrabInput(SDL_GRAB_ON);
    /* dummy read to avoid moving the mouse */
    SDL_GetRelativeMouseState(NULL, NULL);
    gui_grab = 1;
    sdl_update_caption();
}
开发者ID:carriegardner428,项目名称:virtuoso,代码行数:13,代码来源:sdl.c

示例6: SDL_CreateRGBSurfaceFrom

 void InputDeviceSDL2::setMouseIcon(const std::string& name, const Point& hotSpot)
 {
     auto it = m_cursors.find(name);
     if (it == m_cursors.end())
     {
         auto fullPath = oContentManager->findResourceFile(name);
         if (!fullPath.empty())
         {
             Point size;
             auto pngData = onut::loadPNG(fullPath, size);
             if (!pngData.empty())
             {
                 auto pSurface = SDL_CreateRGBSurfaceFrom(pngData.data(),
                                   size.x,
                                   size.y,
                                   32,
                                   size.x * 4,
                                   0x000000ff,
                                   0x0000ff00,
                                   0x00ff0000,
                                   0xff000000);
                 if (pSurface)
                 {
                     auto pCursor = SDL_CreateColorCursor(pSurface, hotSpot.x, hotSpot.y);
                     if (pCursor)
                     {
                         m_cursors[name] = pCursor;
                         SDL_SetCursor(pCursor);
                     }
                     SDL_FreeSurface(pSurface);
                 }
             }
         }
     }
     else
     {
         SDL_SetCursor(it->second);
     }
 }
开发者ID:mchiasson,项目名称:onut,代码行数:39,代码来源:InputDeviceSDL2.cpp

示例7: break_computer_throw_cards_animation

void break_computer_throw_cards_animation(void) {

  /** Computer throw cards animation end function. **/

  game_control->GAME_STATUS = CARDS_THROW ;
  game_control->SAVED_GAME_STATUS = CARDS_THROW ;
  game_control->is_animation_running = false ;

  game_control->cursor_type = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW) ;
  SDL_SetCursor(game_control->cursor_type)  ;

  return ;
}
开发者ID:mrcyberfighter,项目名称:CPoker-1.0.1,代码行数:13,代码来源:animations.c

示例8: I_ShutdownGraphics

void I_ShutdownGraphics(void)
{
    if (initialized)
    {
        SDL_SetCursor(cursors[1]);
        SDL_ShowCursor(1);
        SDL_WM_GrabInput(SDL_GRAB_OFF);

        SDL_QuitSubSystem(SDL_INIT_VIDEO);
    
        initialized = false;
    }
}
开发者ID:hifi-unmaintained,项目名称:chocolate-doom-launcher,代码行数:13,代码来源:i_video.c

示例9: sdl_hide_cursor

static void sdl_hide_cursor(void)
{
    if (!cursor_hide) {
        return;
    }

    if (qemu_input_is_absolute()) {
        SDL_ShowCursor(1);
        SDL_SetCursor(sdl_cursor_hidden);
    } else {
        SDL_SetRelativeMouseMode(SDL_TRUE);
    }
}
开发者ID:AmesianX,项目名称:panda,代码行数:13,代码来源:sdl2.c

示例10: timestamp

		void Cursor::enable()
		{
			if (mAnimationFrames.size() > 1)
			{
				// Animated, set the begin and do everything else in setCurrentFrame()
				mBeginTimeStamp = timestamp();
				mLastFrame = static_cast<size_t>(-1);
			}
			else
			{
				// Not animated, just set the first frame
				SDL_SetCursor(mAnimationFrames.front());
			}
		}
开发者ID:Kobrar,项目名称:fs2open.github.com,代码行数:14,代码来源:cursor.cpp

示例11: SDL_SetRelativeMouseMode

int
SDL_SetRelativeMouseMode(SDL_bool enabled)
{
    SDL_Mouse *mouse = SDL_GetMouse();
    SDL_Window *focusWindow = SDL_GetKeyboardFocus();

    if (enabled == mouse->relative_mode) {
        return 0;
    }

    if (enabled && focusWindow) {
        /* Center it in the focused window to prevent clicks from going through
         * to background windows.
         */
        SDL_SetMouseFocus(focusWindow);
        SDL_WarpMouseInWindow(focusWindow, focusWindow->w/2, focusWindow->h/2);
    }

    /* Set the relative mode */
    if (!enabled && mouse->relative_mode_warp) {
        mouse->relative_mode_warp = SDL_FALSE;
    } else if (enabled && ShouldUseRelativeModeWarp(mouse)) {
        mouse->relative_mode_warp = SDL_TRUE;
    } else if (mouse->SetRelativeMouseMode(enabled) < 0) {
        if (enabled) {
            /* Fall back to warp mode if native relative mode failed */
            mouse->relative_mode_warp = SDL_TRUE;
        }
    }
    mouse->relative_mode = enabled;
    mouse->scale_accum_x = 0.0f;
    mouse->scale_accum_y = 0.0f;

    if (mouse->focus) {
        SDL_UpdateWindowGrab(mouse->focus);

        /* Put the cursor back to where the application expects it */
        if (!enabled) {
            SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y);
        }
    }

    /* Flush pending mouse motion - ideally we would pump events, but that's not always safe */
    SDL_FlushEvent(SDL_MOUSEMOTION);

    /* Update cursor visibility */
    SDL_SetCursor(NULL);

    return 0;
}
开发者ID:jfiguinha,项目名称:Regards,代码行数:50,代码来源:SDL_mouse.c

示例12: initmouse

void initmouse(void)
{
	mouse = 1;
	setmousesens(M_MEDIUM);

	#ifdef PANDORA
	Uint8 noData = 0;
	fakeCursor = SDL_CreateCursor(&noData, &noData, 8, 1, 0, 0);
	SDL_ShowCursor(SDL_ENABLE);
	SDL_SetCursor(fakeCursor);
	#else
	//SDL_ShowCursor(SDL_DISABLE);
	#endif
}
开发者ID:sigt44,项目名称:ravage-sdl,代码行数:14,代码来源:INPUT.CPP

示例13: SDL_SetCursor

	~sdl_cursor_handler()
	{
		m_inited = false;
		if (m_system_cursor)
		{
			SDL_SetCursor(m_system_cursor);
			m_system_cursor = NULL;
		}
		if (m_active_cursor)
		{
			SDL_FreeCursor(m_active_cursor);
			m_active_cursor = NULL;
		}
	}
开发者ID:Heartbroken,项目名称:bikini-iii,代码行数:14,代码来源:gameswf_render_handler_ogl.cpp

示例14: set_cursor

	void set_cursor(gameswf::render_handler::cursor_type cursor) {
		if (!m_inited)
		{
			init();
		}
		
		switch (cursor)
		{
		case gameswf::render_handler::SYSTEM_CURSOR:
			if (m_system_cursor) {
				SDL_SetCursor(m_system_cursor);
			}
			break;

		case gameswf::render_handler::ACTIVE_CURSOR:
			if (m_active_cursor) {
				SDL_SetCursor(m_active_cursor);
			}
			break;
		default:
			assert(0);
		}
	}
开发者ID:Heartbroken,项目名称:bikini-iii,代码行数:23,代码来源:gameswf_render_handler_ogl.cpp

示例15: SetSize

void Cursor::ApplyShape()
{
    CursorShapeInfo& info = shapeInfos_[shape_];
    texture_ = info.texture_;
    imageRect_ = info.imageRect_;
    SetSize(info.imageRect_.Size());

    // If the OS cursor is being shown, define/set SDL cursor shape if necessary
    // Only do this when we are the active UI cursor
    if (GetSubsystem<Input>()->IsMouseVisible() && GetSubsystem<UI>()->GetCursor() == this)
    {
        // Remove existing SDL cursor if is not a system shape while we should be using those, or vice versa
        if (info.osCursor_ && info.systemDefined_ != useSystemShapes_)
        {
            SDL_FreeCursor(info.osCursor_);
            info.osCursor_ = 0;
        }

        // Create SDL cursor now if necessary
        if (!info.osCursor_)
        {
            // Create a system default shape
            if (useSystemShapes_)
            {
                info.osCursor_ = SDL_CreateSystemCursor((SDL_SystemCursor)osCursorLookup[shape_]);
                info.systemDefined_ = true;
                if (!info.osCursor_)
                    LOGERROR("Could not create system cursor");
            }
            // Create from image
            else if (info.image_)
            {
                SDL_Surface* surface = info.image_->GetSDLSurface(info.imageRect_);
                
                if (surface)
                {
                    info.osCursor_ = SDL_CreateColorCursor(surface, info.hotSpot_.x_, info.hotSpot_.y_);
                    info.systemDefined_ = false;
                    if (!info.osCursor_)
                        LOGERROR("Could not create cursor from image " + info.image_->GetName());
                    SDL_FreeSurface(surface);
                }
            }
        }

        if (info.osCursor_)
            SDL_SetCursor(info.osCursor_);
    }
}
开发者ID:SkunkWorks99,项目名称:Urho3D,代码行数:49,代码来源:Cursor.cpp


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