MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / getDisplayIdFromIndex

Function getDisplayIdFromIndex

src/OpenLoco/src/Ui.cpp:84–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82 static void centerWindowOnDisplay(SDL_Window* window, uint32_t displayIndex, int32_t width, int32_t height);
83
84 static SDL_DisplayID getDisplayIdFromIndex(uint32_t displayIndex)
85 {
86 int32_t numDisplays = 0;
87 auto displayIds = SDL_GetDisplays(&numDisplays);
88 if (displayIds == nullptr || numDisplays <= 0)
89 {
90 return SDL_GetPrimaryDisplay();
91 }
92
93 const auto clampedIndex = std::clamp(static_cast<int32_t>(displayIndex), 0, numDisplays - 1);
94 const auto displayId = displayIds[clampedIndex];
95 SDL_free(displayIds);
96 return displayId;
97 }
98
99 static uint32_t getDisplayIndex(SDL_DisplayID displayId)
100 {

Callers 2

getDesktopResolutionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected