Added window properties
This commit is contained in:
parent
305963fe7e
commit
89115c7b5b
|
@ -171,4 +171,31 @@ namespace sdlu
|
||||||
|
|
||||||
SDL_RenderPresent(m_pRenderer);
|
SDL_RenderPresent(m_pRenderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderWindow::SetVisible(bool visible)
|
||||||
|
{
|
||||||
|
RETURN_IF_NULLPTR(m_pWindow);
|
||||||
|
if (visible)
|
||||||
|
SDL_ShowWindow(m_pWindow);
|
||||||
|
else
|
||||||
|
SDL_HideWindow(m_pWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderWindow::SetVsync(bool vsync)
|
||||||
|
{
|
||||||
|
// SDL actually doesn't allow you to change the VSync
|
||||||
|
// flag of a Renderer after it's been created. This
|
||||||
|
// Changes it globally for all other windows
|
||||||
|
SDL_GL_SetSwapInterval(vsync);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderWindow::SetMouseCursorVisible(bool visible)
|
||||||
|
{
|
||||||
|
SDL_ShowCursor(visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderWindow::SetMouseCursorGrabbed(bool grabbed)
|
||||||
|
{
|
||||||
|
SDL_SetWindowGrab(m_pWindow, grabbed ? SDL_TRUE : SDL_FALSE);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -170,6 +170,34 @@ namespace sdlu
|
||||||
*/
|
*/
|
||||||
void Display();
|
void Display();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the windows visibility
|
||||||
|
*
|
||||||
|
* @param[in] visible The new visibility setting
|
||||||
|
*/
|
||||||
|
void SetVisible(bool visible);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief (De)activates VSync !globally!
|
||||||
|
*
|
||||||
|
* @param[in] vsync Wether to enable or disable vsync
|
||||||
|
*/
|
||||||
|
void SetVsync(bool vsync);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Hides/Shows the mouse cursor inside the windos
|
||||||
|
*
|
||||||
|
* @param[in] visible The new visibility of the cursor
|
||||||
|
*/
|
||||||
|
void SetMouseCursorVisible(bool visible);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Traps the mouse cursor inside the window
|
||||||
|
*
|
||||||
|
* @param[in] grabbed Wether to (un)trap the cursor
|
||||||
|
*/
|
||||||
|
void SetMouseCursorGrabbed(bool grabbed);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SDL_Window* m_pWindow; ///< A pointer to the window object
|
SDL_Window* m_pWindow; ///< A pointer to the window object
|
||||||
SDL_Renderer* m_pRenderer; ///< A pointer to the renderer object
|
SDL_Renderer* m_pRenderer; ///< A pointer to the renderer object
|
||||||
|
|
|
@ -6,6 +6,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
MyWindow window(800, 800, "Test");
|
MyWindow window(800, 800, "Test");
|
||||||
SDL_SetWindowTitle(window.GetWindow(), "New Title");
|
SDL_SetWindowTitle(window.GetWindow(), "New Title");
|
||||||
|
window.SetMouseCursorGrabbed(true);
|
||||||
|
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (window.IsOpen())
|
while (window.IsOpen())
|
||||||
|
|
Loading…
Reference in a new issue