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


C++ SDL_GetWindowPosition函数代码示例

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


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

示例1: FreeResources

static void FreeResources(void)
{
  if(g_glcontext)
  {
    SDL_GL_DeleteContext(g_glcontext);
    g_glcontext = NULL;
  }

  if(g_renderer)
  {
    SDL_DestroyRenderer(g_renderer);
    g_renderer = NULL;
  }

  if(g_texture)
  {
    SDL_DestroyTexture(g_texture);
    g_texture = NULL;
  }

  if(g_screen)
  {
    SDL_FreeSurface(g_screen);
    g_screen = NULL;
  }

  if(g_window)
  {
    SDL_GetWindowPosition(g_window, &g_lastx, &g_lasty);
    SDL_DestroyWindow(g_window);
    g_window = NULL;
  }

}
开发者ID:Blonder,项目名称:oricutron,代码行数:34,代码来源:system_sdl.c

示例2: switch

    void InputWrapper::handleWindowEvent(const SDL_Event& evt)
    {
        switch (evt.window.event) {
            case SDL_WINDOWEVENT_ENTER:
                mMouseInWindow = true;
                updateMouseSettings();
                break;
            case SDL_WINDOWEVENT_LEAVE:
                mMouseInWindow = false;
                updateMouseSettings();
                break;
            case SDL_WINDOWEVENT_MOVED:
                // I'm not sure what OSG is using the window position for, but I don't think it's needed,
                // so we ignore window moved events (improves window movement performance)
                break;
            case SDL_WINDOWEVENT_SIZE_CHANGED:
                int w,h;
                SDL_GetWindowSize(mSDLWindow, &w, &h);
                int x,y;
                SDL_GetWindowPosition(mSDLWindow, &x,&y);
                mViewer->getCamera()->getGraphicsContext()->resized(x,y,w,h);

                mViewer->getEventQueue()->windowResize(x,y,w,h);

                if (mWindowListener)
                    mWindowListener->windowResized(w, h);

                break;

            case SDL_WINDOWEVENT_RESIZED:
                // This should also fire SIZE_CHANGED, so no need to handle
                break;

            case SDL_WINDOWEVENT_FOCUS_GAINED:
                mWindowHasFocus = true;
                updateMouseSettings();
                if (mWindowListener)
                    mWindowListener->windowFocusChange(true);

                break;
            case SDL_WINDOWEVENT_FOCUS_LOST:
                mWindowHasFocus = false;
                updateMouseSettings();
                if (mWindowListener)
                    mWindowListener->windowFocusChange(false);
                break;
            case SDL_WINDOWEVENT_CLOSE:
                break;
            case SDL_WINDOWEVENT_SHOWN:
            case SDL_WINDOWEVENT_RESTORED:
                if (mWindowListener)
                    mWindowListener->windowVisibilityChange(true);
                break;
            case SDL_WINDOWEVENT_HIDDEN:
            case SDL_WINDOWEVENT_MINIMIZED:
                if (mWindowListener)
                    mWindowListener->windowVisibilityChange(false);
                break;
        }
    }
开发者ID:Allofich,项目名称:openmw,代码行数:60,代码来源:sdlinputwrapper.cpp

示例3: SDL_GetWindowPosition

void Window::getPosition(int &x, int &y, int &displayindex)
{
	if (!window)
	{
		x = y =  0;
		displayindex = 0;
		return;
	}

	displayindex = std::max(SDL_GetWindowDisplayIndex(window), 0);

	SDL_GetWindowPosition(window, &x, &y);

	// In SDL <= 2.0.3, fullscreen windows are always reported as 0,0. In every
	// other case we need to convert the position from global coordinates to the
	// monitor's coordinate space.
	if (x != 0 || y != 0)
	{
		SDL_Rect displaybounds = {};
		SDL_GetDisplayBounds(displayindex, &displaybounds);

		x -= displaybounds.x;
		y -= displaybounds.y;
	}
}
开发者ID:MikuAuahDark,项目名称:livesim4,代码行数:25,代码来源:Window.cpp

示例4: SDL_GetWindowPosition

	MyGUI::IntCoord BaseManager::getWindowCoord()
	{
		int left, top, width, height;
		SDL_GetWindowPosition(mWindow, &left, &top);
		SDL_GetWindowSize(mWindow, &width, &height);
		return MyGUI::IntCoord(left, top, width, height);
	}
开发者ID:atchouprakov,项目名称:mygui,代码行数:7,代码来源:BaseManager.cpp

示例5: SDL_GetWindowPosition

    glm::uvec2 Window::getPosition() const
    {
        int x, y;
        SDL_GetWindowPosition(window_, &x, &y);

        return {x, y};
    }
开发者ID:Dante12129,项目名称:Pancake,代码行数:7,代码来源:Window.cpp

示例6: SDL_GetGlobalMouseState

    math::vector<int, 2> window::get_mouse_position() const
    {
        int x, y;
        SDL_GetGlobalMouseState(&x, &y);

        int window_x, window_y;
        SDL_GetWindowPosition(handle.get(), &window_x, &window_y);

        x -= window_x;
        y -= window_y;

        // SDL_GetGlobalMouseState and SDL_GetWindowPosition return "screen
        // coordinates", as in scaled values. We'll need to convert these to
        // pixels before we can do anything with them.

        // TODO: is this also the case on Windows?

        // TODO: seeing as get_position/set_position and get_size/set_size
        // operate in "screen coordinates", there might also be use for a
        // variant of get_mouse_position that returns "screen coordinates".

        x *= get_backbuffer_width() / get_width();
        y *= get_backbuffer_height() / get_height();

        return { x, y };
    }
开发者ID:aleksijuvani,项目名称:polygonist,代码行数:26,代码来源:window.cpp

示例7: SDL_GetWindowPosition

S32 VideoSystem::getWindowPositionCoord(bool getX)
{
   S32 x, y;
   SDL_GetWindowPosition(DisplayManager::getScreenInfo()->sdlWindow, &x, &y);

   return getX ? x : y;
}
开发者ID:LibreGames,项目名称:bitfighter,代码行数:7,代码来源:VideoSystem.cpp

示例8: _gut_savebnds

static inline bool _gut_savebnds(GutCore *core) {
	if (gut.core->window.mode != GUT_MODE_WINDOWED) {
		// bounds undefined, use desktop bounds
		SDL_Rect bounds;
		if (!_gut_getbnds(&bounds))
			return false;
		int x, y;
		x = (bounds.w - gut.window.width) / 2;
		if (x < 0) x = 0;
		y = (bounds.h - gut.window.height) / 2;
		if (y < 0) y = 0;
		core->window.windowbounds.x = x;
		core->window.windowbounds.y = y;
		core->window.windowbounds.w = gut.window.width;
		core->window.windowbounds.h = gut.window.height;
		return true;
	}
	// recycle old bounds
	SDL_GetWindowPosition(
		core->window.handle,
		&core->window.windowbounds.x, &core->window.windowbounds.y
	);
	SDL_GetWindowSize(
		core->window.handle,
		&core->window.windowbounds.w, &core->window.windowbounds.h
	);
	return true;
}
开发者ID:FolkertVanVerseveld,项目名称:gut,代码行数:28,代码来源:gut.c

示例9: SDL_GetWindowPosition

/** Returns the size and location of the window when it is restored */
bool FLinuxWindow::GetRestoredDimensions(int32& X, int32& Y, int32& Width, int32& Height)
{
	SDL_GetWindowPosition(HWnd, &X, &Y);
	SDL_GetWindowSize(HWnd, &Width, &Height);

	return true;
}
开发者ID:magetron,项目名称:UnrealEngine4-mod,代码行数:8,代码来源:LinuxWindow.cpp

示例10: SDL_GetWindowPosition

void Window::updatePosition()
{
	int x, y;
	SDL_GetWindowPosition(pointer, &x, &y);

	position.set(x, y);
}
开发者ID:Sackzement,项目名称:Heroes,代码行数:7,代码来源:Window.cpp

示例11: SDL_GetWindowPosition

const struct point *video_get_position( )
{
	static struct point point;

	SDL_GetWindowPosition( video_window, &point.x, &point.y );
	return &point;
}
开发者ID:Protovision,项目名称:moonbase,代码行数:7,代码来源:video.c

示例12: SDL_GetWindowPosition

    math::vector<int, 2> window::get_position() const
    {
        int x = 0, y = 0;

        SDL_GetWindowPosition(handle.get(), &x, &y);

        return { x, y };
    }
开发者ID:aleksijuvani,项目名称:polygonist,代码行数:8,代码来源:window.cpp

示例13: SDL_GetMouseFocus

	point sdl_window::mouse_position() const
	{
		int x, y;
		SDL_Window* mouseFocus = SDL_GetMouseFocus();
		SDL_GetMouseState(&x, &y);
		if (mouseFocus != 0)
		{
			int mfx, mfy;
			SDL_GetWindowPosition(mouseFocus, &mfx, &mfy);
			x += mfx;
			y += mfy;
			SDL_GetWindowPosition(iHandle, &mfx, &mfy);
			x -= mfx;
			y -= mfy;
		}
		return point(static_cast<coordinate>(x), static_cast<coordinate>(y));
	}
开发者ID:basisbit,项目名称:neogfx,代码行数:17,代码来源:sdl_window.cpp

示例14: SDL_GetMouseFocus

void FLinuxCursor::SetPosition( const int32 X, const int32 Y )
{
	int WndX, WndY;

	SDL_HWindow WndFocus = SDL_GetMouseFocus();

	SDL_GetWindowPosition( WndFocus, &WndX, &WndY );	//	get top left
	SDL_WarpMouseInWindow( NULL, X - WndX, Y - WndY );
}
开发者ID:Foreven,项目名称:Unreal4-1,代码行数:9,代码来源:LinuxCursor.cpp

示例15: SDL_GetMouseFocus

GHOST_TSuccess GHOST_SystemSDL::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y)
{
  int x_win, y_win;
  SDL_Window *win = SDL_GetMouseFocus();
  SDL_GetWindowPosition(win, &x_win, &y_win);

  SDL_WarpMouseInWindow(win, x - x_win, y - y_win);
  return GHOST_kSuccess;
}
开发者ID:wangyxuan,项目名称:blender,代码行数:9,代码来源:GHOST_SystemSDL.cpp


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