#include <WindowManager.hxx>
Definition at line 19 of file WindowManager.hxx.
◆ WindowManager() [1/2]
◆ WindowManager() [2/2]
WindowManager::WindowManager |
( |
| ) |
|
|
private |
Construct a new WindowManager object.
- Exceptions
-
UIError | if window or renderer creation fails, or if the window icon cannot be loaded |
ConfigurationError | if the path to the window icon doesn't exist |
Definition at line 14 of file WindowManager.cxx.
16 Uint32 windowFlags = 0;
17 Uint32 rendererFlags = 0;
21 windowFlags = SDL_WINDOW_FULLSCREEN;
23 SDL_GetDesktopDisplayMode(0, &mode);
28 #ifdef TESTING_ENABLED
29 windowFlags = SDL_WINDOW_HIDDEN;
30 m_window = SDL_CreateWindow(
m_title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, windowFlags);
41 #if defined(TESTING_ENABLED) && defined(__linux)
48 SDL_RendererInfo info;
60 SDL_Surface *icon = IMG_Load(iconFName.c_str());
63 throw UIError(
TRACE_INFO "Could not load icon " + iconFName +
": " + IMG_GetError());
66 SDL_FreeSurface(icon);
◆ ~WindowManager()
WindowManager::~WindowManager |
( |
| ) |
|
|
private |
◆ destroyImGuiRenderer()
void WindowManager::destroyImGuiRenderer |
( |
| ) |
|
|
private |
shuts down the renderer for ImGui and the ImGui context.
Definition at line 181 of file WindowManager.cxx.
183 ImGui_ImplSDLRenderer_Shutdown();
184 ImGui_ImplSDL2_Shutdown();
185 ImGui::DestroyContext();
◆ getRenderer()
SDL_Renderer* WindowManager::getRenderer |
( |
| ) |
const |
|
inline |
get SDL Renderer
- Returns
- Pointer to the SDL_Renderer
Definition at line 38 of file WindowManager.hxx.
◆ getSupportedScreenResolutions()
const std::vector<std::unique_ptr<SDL_DisplayMode> >& WindowManager::getSupportedScreenResolutions |
( |
| ) |
const |
|
inline |
◆ getWindow()
SDL_Window* WindowManager::getWindow |
( |
| ) |
const |
|
inline |
get SDL Window
- Returns
- Pointer to the SDL_Window
Definition at line 43 of file WindowManager.hxx.
◆ initializeImguiRenderer()
void WindowManager::initializeImguiRenderer |
( |
| ) |
|
|
private |
Sets up platform/renderer backends and theme.
Definition at line 169 of file WindowManager.cxx.
172 IMGUI_CHECKVERSION();
173 ImGui::CreateContext();
174 ImGui::StyleColorsDark();
◆ initializeScreenResolutions()
void WindowManager::initializeScreenResolutions |
( |
| ) |
|
|
private |
Definition at line 141 of file WindowManager.cxx.
147 for (
int modeIndex = 0; modeIndex <= SDL_GetNumDisplayModes(
m_activeDisplay); modeIndex++)
149 std::unique_ptr<SDL_DisplayMode> displayMode =
150 std::make_unique<SDL_DisplayMode>((SDL_DisplayMode{SDL_PIXELFORMAT_UNKNOWN, 0, 0, 0,
nullptr}));
152 auto isResolitionExist = [&](
int w,
int h)
155 [w, h](
auto &mode) { return (mode->w == w) && (mode->h == h); });
159 if (SDL_GetDisplayMode(
m_activeDisplay, modeIndex, displayMode.get()) == 0)
161 if (isResolitionExist(displayMode->w, displayMode->h))
◆ newImGuiFrame()
void WindowManager::newImGuiFrame |
( |
| ) |
|
creates and renders a new ImGui frame
Definition at line 224 of file WindowManager.cxx.
226 ImGui_ImplSDLRenderer_NewFrame();
227 ImGui_ImplSDL2_NewFrame();
◆ operator=()
◆ renderScreen()
void WindowManager::renderScreen |
( |
| ) |
|
Definition at line 231 of file WindowManager.cxx.
234 SDL_SetRenderDrawColor(
m_renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
237 ImGui_ImplSDLRenderer_RenderDrawData(ImGui::GetDrawData());
◆ setFullScreenMode()
sets the game's window mode
Changes the game's window mode to fullscreen, borderless, or windowed
- Parameters
-
mode | the new window mode, WINDOWED, BORDERLESS, or FULLSCREEN |
Definition at line 96 of file WindowManager.cxx.
106 SDL_SetWindowFullscreen(
m_window, 0);
109 SDL_SetWindowFullscreen(
m_window, SDL_WINDOW_FULLSCREEN);
112 SDL_DisplayMode desktopScreenMode;
113 if (SDL_GetDesktopDisplayMode(0, &desktopScreenMode) != 0)
115 LOG(
LOG_INFO) <<
"SDL_GetDesktopDisplayMode failed: " << SDL_GetError();
123 SDL_SetWindowFullscreen(
m_window, 0);
124 SDL_SetWindowFullscreen(
m_window, SDL_WINDOW_FULLSCREEN_DESKTOP);
◆ setScreenResolution()
void WindowManager::setScreenResolution |
( |
int |
mode | ) |
|
Definition at line 188 of file WindowManager.cxx.
206 SDL_SetWindowFullscreen(
m_window, 0);
207 SDL_SetWindowFullscreen(
m_window, SDL_WINDOW_FULLSCREEN);
211 SDL_SetWindowPosition(
m_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
◆ setWindowTitle()
void WindowManager::setWindowTitle |
( |
const std::string & |
title | ) |
|
sets title of the window
- Parameters
-
title | the new title of the window |
Definition at line 135 of file WindowManager.cxx.
◆ toggleFullScreen()
void WindowManager::toggleFullScreen |
( |
| ) |
const |
◆ m_activeDisplay
int WindowManager::m_activeDisplay = 0 |
|
private |
◆ m_numOfDisplays
int WindowManager::m_numOfDisplays = 0 |
|
private |
◆ m_renderer
SDL_Renderer* WindowManager::m_renderer = nullptr |
|
private |
◆ m_resolutions
std::vector<std::unique_ptr<SDL_DisplayMode> > WindowManager::m_resolutions |
|
private |
◆ m_title
◆ m_window
SDL_Window* WindowManager::m_window = nullptr |
|
private |
◆ m_windowIcon
const std::string WindowManager::m_windowIcon = "resources/images/app_icons/cytopia_icon.png" |
|
private |
◆ Singleton< WindowManager >
The documentation for this class was generated from the following files: