From 8796b2ece90350fd19400d005680619897bd624f Mon Sep 17 00:00:00 2001 From: SR_team Date: Thu, 7 Jul 2022 08:31:37 +0300 Subject: [PATCH] SDL2: Implement subsystem selection --- src/gl/gl3device.cpp | 36 +++++++++++++++++++----------------- src/gl/rwgl3impl.h | 2 +- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/gl/gl3device.cpp b/src/gl/gl3device.cpp index 014571e..1ad5fea 100644 --- a/src/gl/gl3device.cpp +++ b/src/gl/gl3device.cpp @@ -1553,12 +1553,15 @@ startSDL2(void) SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, profiles[i].major); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, profiles[i].minor); + SDL_Rect bounds; + SDL_GetDisplayBounds(glGlobals.currentMonitor, &bounds); + if(mode->flags & VIDEOMODEEXCLUSIVE) { - win = SDL_CreateWindow(glGlobals.winTitle, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, mode->mode.w, mode->mode.h, SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN); + win = SDL_CreateWindow(glGlobals.winTitle, bounds.x, bounds.y, mode->mode.w, mode->mode.h, SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN); if (win) SDL_SetWindowDisplayMode(win, &mode->mode); } else { - win = SDL_CreateWindow(glGlobals.winTitle, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, glGlobals.winWidth, glGlobals.winHeight, SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL); + win = SDL_CreateWindow(glGlobals.winTitle, bounds.x, bounds.y, glGlobals.winWidth, glGlobals.winHeight, SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL); if (win) SDL_SetWindowDisplayMode(win, NULL); } @@ -1940,7 +1943,20 @@ deviceSystemSDL2(DeviceReq req, void *arg, int32 n) case DEVICEFINALIZE: return finalizeOpenGL(); - // TODO: implement subsystems + case DEVICEGETNUMSUBSYSTEMS: + return SDL_GetNumVideoDisplays(); + case DEVICEGETSUBSSYSTEMINFO: + if (n > SDL_GetNumVideoDisplays()) + return 0; + strncpy(((SubSystemInfo*)arg)->name, SDL_GetDisplayName(n), sizeof(SubSystemInfo::name)); + return 1; + case DEVICEGETCURRENTSUBSYSTEM: + return glGlobals.currentMonitor; + case DEVICESETSUBSYSTEM: + if (n > SDL_GetNumVideoDisplays()) + return 0; + glGlobals.currentMonitor = n; + return 1; case DEVICEGETNUMVIDEOMODES: return glGlobals.numModes; @@ -1977,20 +1993,6 @@ deviceSystemSDL2(DeviceReq req, void *arg, int32 n) case DEVICESETMULTISAMPLINGLEVELS: glGlobals.numSamples = (uint32)n; return 1; - case DEVICEGETNUMSUBSYSTEMS: - return SDL_GetNumVideoDisplays(); - case DEVICEGETSUBSSYSTEMINFO: - if (n > SDL_GetNumVideoDisplays()) - return 0; - strncpy(((SubSystemInfo*)arg)->name, SDL_GetDisplayName(n), sizeof(SubSystemInfo::name)); - return 1; - case DEVICEGETCURRENTSUBSYSTEM: - return 0; // FIXME: Returns first monitor index, instead of current - case DEVICESETSUBSYSTEM: - if (n > SDL_GetNumVideoDisplays()) - return 0; - // TODO: Set monitor index to be use - return 1; default: assert(0 && "not implemented"); return 0; diff --git a/src/gl/rwgl3impl.h b/src/gl/rwgl3impl.h index 39f0050..3176eb5 100644 --- a/src/gl/rwgl3impl.h +++ b/src/gl/rwgl3impl.h @@ -45,8 +45,8 @@ struct GlGlobals GLFWmonitor *monitor; int numMonitors; - int currentMonitor; #endif + int currentMonitor; DisplayMode *modes; int numModes;