本文整理汇总了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;
}
}
示例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;
}
}
示例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;
}
}
示例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);
}
示例5: SDL_GetWindowPosition
glm::uvec2 Window::getPosition() const
{
int x, y;
SDL_GetWindowPosition(window_, &x, &y);
return {x, y};
}
示例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 };
}
示例7: SDL_GetWindowPosition
S32 VideoSystem::getWindowPositionCoord(bool getX)
{
S32 x, y;
SDL_GetWindowPosition(DisplayManager::getScreenInfo()->sdlWindow, &x, &y);
return getX ? x : y;
}
示例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;
}
示例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;
}
示例10: SDL_GetWindowPosition
void Window::updatePosition()
{
int x, y;
SDL_GetWindowPosition(pointer, &x, &y);
position.set(x, y);
}
示例11: SDL_GetWindowPosition
const struct point *video_get_position( )
{
static struct point point;
SDL_GetWindowPosition( video_window, &point.x, &point.y );
return &point;
}
示例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 };
}
示例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));
}
示例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 );
}
示例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;
}