Skip to content

Commit b6bace7

Browse files
committed
default primary display is no longer 0!
1 parent c9fdec0 commit b6bace7

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Source/Managers/WindowMan.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
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() {
9699
void 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, &currentDisplayBounds);
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()));
@@ -800,4 +815,4 @@ void WindowMan::Present() {
800815
SDL_GL_SwapWindow(m_MultiDisplayWindows.at(i).get());
801816
}
802817
}
803-
}
818+
}

0 commit comments

Comments
 (0)