9 #include "imgui_impl_sdl.h"
10 #include "imgui_impl_sdlrenderer.h"
12 #include <SDL_image.h>
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);
88 SDL_SetWindowFullscreen(
m_window, SDL_WINDOW_FULLSCREEN);
92 SDL_SetWindowFullscreen(
m_window, 0);
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);
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))
172 IMGUI_CHECKVERSION();
173 ImGui::CreateContext();
174 ImGui::StyleColorsDark();
183 ImGui_ImplSDLRenderer_Shutdown();
184 ImGui_ImplSDL2_Shutdown();
185 ImGui::DestroyContext();
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);
226 ImGui_ImplSDLRenderer_NewFrame();
227 ImGui_ImplSDL2_NewFrame();
234 SDL_SetRenderDrawColor(
m_renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
237 ImGui_ImplSDLRenderer_RenderDrawData(ImGui::GetDrawData());