11#include " WindowMan.h"
2+ #include " RTEError.h"
3+ #include " SDL3/SDL_error.h"
4+ #include " SDL3/SDL_video.h"
25#include " SettingsMan.h"
36#include " FrameMan.h"
47#include " ActivityMan.h"
@@ -96,7 +99,20 @@ void WindowMan::Destroy() {
9699void WindowMan::Initialize () {
97100 SDL_free (SDL_GetDisplays (&m_NumDisplays));
98101
99- SDL_Rect currentDisplayBounds;
102+ m_PrimaryWindowDisplayIndex = SDL_GetPrimaryDisplay ();
103+ if (m_PrimaryWindowDisplayIndex == 0 ) {
104+ g_ConsoleMan.PrintString (" ERROR: Failed to get primary display!" + std::string (SDL_GetError ()));
105+ int count{0 };
106+ SDL_DisplayID* displays = SDL_GetDisplays (&count);
107+ if (displays) {
108+ m_PrimaryWindowDisplayIndex = displays[0 ];
109+ } else {
110+ RTEAbort (" No displays detetected somehow! " + std::string (SDL_GetError ()));
111+ }
112+ SDL_free (displays);
113+ }
114+
115+ SDL_Rect currentDisplayBounds{};
100116 SDL_GetDisplayBounds (m_PrimaryWindowDisplayIndex, ¤tDisplayBounds);
101117
102118 m_PrimaryWindowDisplayWidth = currentDisplayBounds.w ;
@@ -160,7 +176,6 @@ void WindowMan::CreatePrimaryWindow() {
160176
161177 int windowPosX = (m_ResX * m_ResMultiplier <= m_PrimaryWindowDisplayWidth) ? SDL_WINDOWPOS_CENTERED : (m_MaxResX - (m_ResX * m_ResMultiplier)) / 2 ;
162178 int windowPosY = SDL_WINDOWPOS_CENTERED;
163- int windowFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE;
164179
165180 SDL_PropertiesID windowProps = SDL_CreateProperties ();
166181 RTEAssert (windowProps, " Unable to create window properties! " + std::string (SDL_GetError ()));
@@ -798,4 +813,4 @@ void WindowMan::Present() {
798813 SDL_GL_SwapWindow (m_MultiDisplayWindows.at (i).get ());
799814 }
800815 }
801- }
816+ }
0 commit comments