Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL2: Implement subsystems #105

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/gl/gl3device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/gl/rwgl3impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ struct GlGlobals

GLFWmonitor *monitor;
int numMonitors;
int currentMonitor;
#endif
int currentMonitor;

DisplayMode *modes;
int numModes;
Expand Down