mirror of
https://github.com/aap/librw.git
synced 2024-12-12 13:35:43 +00:00
gl3/sdl2: implement subsystems
This commit is contained in:
parent
a6139bc44d
commit
8fa4885a1b
@ -1513,7 +1513,10 @@ openSDL2(EngineOpenParams *openparams)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
makeVideoModeList(0);
|
glGlobals.currentDisplay = 0;
|
||||||
|
glGlobals.numDisplays = SDL_GetNumVideoDisplays();
|
||||||
|
|
||||||
|
makeVideoModeList(glGlobals.currentDisplay);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1627,16 +1630,16 @@ addVideoMode(const GLFWvidmode *mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
makeVideoModeList(void)
|
makeVideoModeList(GLFWmonitor *monitor)
|
||||||
{
|
{
|
||||||
int i, num;
|
int i, num;
|
||||||
const GLFWvidmode *modes;
|
const GLFWvidmode *modes;
|
||||||
|
|
||||||
modes = glfwGetVideoModes(glGlobals.monitor, &num);
|
modes = glfwGetVideoModes(monitor, &num);
|
||||||
rwFree(glGlobals.modes);
|
rwFree(glGlobals.modes);
|
||||||
glGlobals.modes = rwNewT(DisplayMode, num+1, ID_DRIVER | MEMDUR_EVENT);
|
glGlobals.modes = rwNewT(DisplayMode, num+1, ID_DRIVER | MEMDUR_EVENT);
|
||||||
|
|
||||||
glGlobals.modes[0].mode = *glfwGetVideoMode(glGlobals.monitor);
|
glGlobals.modes[0].mode = *glfwGetVideoMode(monitor);
|
||||||
glGlobals.modes[0].flags = 0;
|
glGlobals.modes[0].flags = 0;
|
||||||
glGlobals.numModes = 1;
|
glGlobals.numModes = 1;
|
||||||
|
|
||||||
@ -1670,7 +1673,7 @@ openGLFW(EngineOpenParams *openparams)
|
|||||||
|
|
||||||
glGlobals.monitor = glfwGetMonitors(&glGlobals.numMonitors)[0];
|
glGlobals.monitor = glfwGetMonitors(&glGlobals.numMonitors)[0];
|
||||||
|
|
||||||
makeVideoModeList();
|
makeVideoModeList(glGlobals.monitor);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1940,7 +1943,27 @@ deviceSystemSDL2(DeviceReq req, void *arg, int32 n)
|
|||||||
case DEVICEFINALIZE:
|
case DEVICEFINALIZE:
|
||||||
return finalizeOpenGL();
|
return finalizeOpenGL();
|
||||||
|
|
||||||
// TODO: implement subsystems
|
|
||||||
|
case DEVICEGETNUMSUBSYSTEMS:
|
||||||
|
return glGlobals.numDisplays;
|
||||||
|
|
||||||
|
case DEVICEGETCURRENTSUBSYSTEM:
|
||||||
|
return glGlobals.currentDisplay;
|
||||||
|
|
||||||
|
case DEVICESETSUBSYSTEM:
|
||||||
|
if (n >= SDL_GetNumVideoDisplays())
|
||||||
|
return 0;
|
||||||
|
glGlobals.currentDisplay = n;
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
case DEVICEGETSUBSSYSTEMINFO: {
|
||||||
|
const char *display_name = SDL_GetDisplayName(n);
|
||||||
|
if (display_name == nil)
|
||||||
|
return 0;
|
||||||
|
strncpy(((SubSystemInfo*)arg)->name, display_name, sizeof(SubSystemInfo::name));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
case DEVICEGETNUMVIDEOMODES:
|
case DEVICEGETNUMVIDEOMODES:
|
||||||
return glGlobals.numModes;
|
return glGlobals.numModes;
|
||||||
|
@ -39,6 +39,9 @@ struct GlGlobals
|
|||||||
SDL_Window **pWindow;
|
SDL_Window **pWindow;
|
||||||
SDL_Window *window;
|
SDL_Window *window;
|
||||||
SDL_GLContext glcontext;
|
SDL_GLContext glcontext;
|
||||||
|
|
||||||
|
int numDisplays;
|
||||||
|
int currentDisplay;
|
||||||
#else
|
#else
|
||||||
GLFWwindow **pWindow;
|
GLFWwindow **pWindow;
|
||||||
GLFWwindow *window;
|
GLFWwindow *window;
|
||||||
|
Loading…
Reference in New Issue
Block a user