mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 10:48:51 -05:00
Moved platform specific monitor list creation part to separate functions.
This commit is contained in:
parent
6f970f5753
commit
f228d23024
|
@ -65,6 +65,13 @@
|
||||||
// extensions and not all operating systems come with an up-to-date version
|
// extensions and not all operating systems come with an up-to-date version
|
||||||
#include "../support/GL/glext.h"
|
#include "../support/GL/glext.h"
|
||||||
|
|
||||||
|
typedef struct _GLFWhints _GLFWhints;
|
||||||
|
typedef struct _GLFWwndconfig _GLFWwndconfig;
|
||||||
|
typedef struct _GLFWfbconfig _GLFWfbconfig;
|
||||||
|
typedef struct _GLFWwindow _GLFWwindow;
|
||||||
|
typedef struct _GLFWlibrary _GLFWlibrary;
|
||||||
|
typedef struct _GLFWmonitor _GLFWmonitor;
|
||||||
|
|
||||||
#if defined(_GLFW_COCOA_NSGL)
|
#if defined(_GLFW_COCOA_NSGL)
|
||||||
#include "cocoa_platform.h"
|
#include "cocoa_platform.h"
|
||||||
#elif defined(_GLFW_WIN32_WGL)
|
#elif defined(_GLFW_WIN32_WGL)
|
||||||
|
@ -75,14 +82,6 @@
|
||||||
#error "No supported platform selected"
|
#error "No supported platform selected"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct _GLFWhints _GLFWhints;
|
|
||||||
typedef struct _GLFWwndconfig _GLFWwndconfig;
|
|
||||||
typedef struct _GLFWfbconfig _GLFWfbconfig;
|
|
||||||
typedef struct _GLFWwindow _GLFWwindow;
|
|
||||||
typedef struct _GLFWlibrary _GLFWlibrary;
|
|
||||||
typedef struct _GLFWmonitor _GLFWmonitor;
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// Window hints, set by glfwOpenWindowHint and consumed by glfwOpenWindow
|
// Window hints, set by glfwOpenWindowHint and consumed by glfwOpenWindow
|
||||||
// A bucket of semi-random stuff lumped together for historical reasons
|
// A bucket of semi-random stuff lumped together for historical reasons
|
||||||
|
@ -388,9 +387,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig);
|
||||||
GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig);
|
GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig);
|
||||||
|
|
||||||
// Monitor management (monitor.c)
|
// Monitor management (monitor.c)
|
||||||
|
void _glfwInitMonitors(void);
|
||||||
void _glfwTerminateMonitors(void);
|
void _glfwTerminateMonitors(void);
|
||||||
|
|
||||||
// platform specific (*_monitor.c)
|
|
||||||
_GLFWmonitor* _glfwDestroyMonitor(_GLFWmonitor* monitor);
|
|
||||||
|
|
||||||
#endif // _internal_h_
|
#endif // _internal_h_
|
||||||
|
|
|
@ -145,6 +145,15 @@ GLFWAPI void glfwSetMonitorDeviceCallback(GLFWmonitordevicefun cbfun)
|
||||||
_glfwLibrary.monitorCallback= cbfun;
|
_glfwLibrary.monitorCallback= cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Initialize the monitor list.
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void _glfwInitMonitors(void)
|
||||||
|
{
|
||||||
|
_glfwLibrary.monitorListHead = _glfwCreateMonitors();
|
||||||
|
}
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Delete the monitor list.
|
// Delete the monitor list.
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
|
@ -83,29 +83,21 @@ _GLFWmonitor* _glfwDestroyMonitor(_GLFWmonitor* monitor)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: This is ugly. The platform should only allocate a list of the current devices.
|
_GLFWmonitor* _glfwCreateMonitors(void)
|
||||||
// The platform independent code should be in charge of the handling for the initial
|
|
||||||
// setup, refreshing and freeing the list.
|
|
||||||
void _glfwInitMonitors(void)
|
|
||||||
{
|
{
|
||||||
_GLFWmonitor** curMonitor;
|
|
||||||
|
|
||||||
DISPLAY_DEVICE adapter;
|
DISPLAY_DEVICE adapter;
|
||||||
DWORD adapterNum;
|
DWORD adapterNum;
|
||||||
|
|
||||||
DISPLAY_DEVICE monitor;
|
DISPLAY_DEVICE monitor;
|
||||||
|
|
||||||
DEVMODE setting;
|
DEVMODE setting;
|
||||||
DWORD settingNum;
|
_GLFWmonitor* monitorList;
|
||||||
|
_GLFWmonitor** curMonitor;
|
||||||
curMonitor = &_glfwLibrary.monitorListHead;
|
|
||||||
|
|
||||||
adapter.cb = sizeof(DISPLAY_DEVICE);
|
adapter.cb = sizeof(DISPLAY_DEVICE);
|
||||||
adapterNum = 0;
|
adapterNum = 0;
|
||||||
|
|
||||||
monitor.cb = sizeof(DISPLAY_DEVICE);
|
monitor.cb = sizeof(DISPLAY_DEVICE);
|
||||||
setting.dmSize = sizeof(DEVMODE);
|
setting.dmSize = sizeof(DEVMODE);
|
||||||
settingNum = 0;
|
monitorList = NULL;
|
||||||
|
curMonitor = &monitorList;
|
||||||
|
|
||||||
while (EnumDisplayDevices(NULL, adapterNum++, &adapter, 0))
|
while (EnumDisplayDevices(NULL, adapterNum++, &adapter, 0))
|
||||||
{
|
{
|
||||||
|
@ -121,36 +113,16 @@ void _glfwInitMonitors(void)
|
||||||
|
|
||||||
curMonitor = _glfwCreateMonitor(curMonitor, &adapter, &monitor, &setting);
|
curMonitor = _glfwCreateMonitor(curMonitor, &adapter, &monitor, &setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return monitorList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwRefreshMonitors(void)
|
void _glfwRefreshMonitors(void)
|
||||||
{
|
{
|
||||||
DISPLAY_DEVICE adapter;
|
|
||||||
DWORD adapterNum = 0;
|
|
||||||
|
|
||||||
DISPLAY_DEVICE monitor;
|
|
||||||
|
|
||||||
DEVMODE setting;
|
|
||||||
|
|
||||||
_GLFWmonitor* newMonitorList = NULL;
|
|
||||||
_GLFWmonitor** curMonitor = &newMonitorList;
|
|
||||||
|
|
||||||
_GLFWmonitor* curNewMonitor;
|
_GLFWmonitor* curNewMonitor;
|
||||||
_GLFWmonitor* curOldMonitor;
|
_GLFWmonitor* curOldMonitor;
|
||||||
|
|
||||||
while (EnumDisplayDevices(NULL, adapterNum++, &adapter, 0))
|
curNewMonitor = _glfwCreateMonitors();
|
||||||
{
|
|
||||||
if (adapter.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER || !(adapter.StateFlags & DISPLAY_DEVICE_ACTIVE))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
EnumDisplaySettingsEx(adapter.DeviceName, ENUM_CURRENT_SETTINGS, &setting, EDS_ROTATEDMODE);
|
|
||||||
|
|
||||||
EnumDisplayDevices(adapter.DeviceName, 0, &monitor, 0);
|
|
||||||
|
|
||||||
curMonitor = _glfwCreateMonitor(curMonitor, &adapter, &monitor, &setting);
|
|
||||||
}
|
|
||||||
|
|
||||||
curNewMonitor = newMonitorList;
|
|
||||||
curOldMonitor = _glfwLibrary.monitorListHead;
|
curOldMonitor = _glfwLibrary.monitorListHead;
|
||||||
|
|
||||||
while (_glfwLibrary.monitorCallback && (curNewMonitor || curOldMonitor))
|
while (_glfwLibrary.monitorCallback && (curNewMonitor || curOldMonitor))
|
||||||
|
|
|
@ -339,6 +339,8 @@ void _glfwInitTimer(void);
|
||||||
// Monitor support
|
// Monitor support
|
||||||
void _glfwInitMonitors(void);
|
void _glfwInitMonitors(void);
|
||||||
void _glfwRefreshMonitors(void);
|
void _glfwRefreshMonitors(void);
|
||||||
|
_GLFWmonitor* _glfwCreateMonitors(void);
|
||||||
|
_GLFWmonitor* _glfwDestroyMonitor(_GLFWmonitor* monitor);
|
||||||
|
|
||||||
// Fullscreen support
|
// Fullscreen support
|
||||||
void _glfwSetVideoMode(int* width, int* height,
|
void _glfwSetVideoMode(int* width, int* height,
|
||||||
|
|
|
@ -77,9 +77,11 @@ _GLFWmonitor* _glfwDestroyMonitor(_GLFWmonitor* monitor)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwInitMonitors(void)
|
_GLFWmonitor* _glfwCreateMonitors(void)
|
||||||
{
|
{
|
||||||
_glfwLibrary.monitorListHead = NULL;
|
_GLFWmonitor* monitorList;
|
||||||
|
|
||||||
|
monitorList = NULL;
|
||||||
|
|
||||||
if (_glfwLibrary.X11.RandR.available)
|
if (_glfwLibrary.X11.RandR.available)
|
||||||
{
|
{
|
||||||
|
@ -88,7 +90,7 @@ void _glfwInitMonitors(void)
|
||||||
int outputIDX;
|
int outputIDX;
|
||||||
_GLFWmonitor** curMonitor;
|
_GLFWmonitor** curMonitor;
|
||||||
|
|
||||||
curMonitor = &_glfwLibrary.monitorListHead;
|
curMonitor = &monitorList;
|
||||||
|
|
||||||
resources = XRRGetScreenResources(_glfwLibrary.X11.display,
|
resources = XRRGetScreenResources(_glfwLibrary.X11.display,
|
||||||
_glfwLibrary.X11.root);
|
_glfwLibrary.X11.root);
|
||||||
|
@ -126,5 +128,7 @@ void _glfwInitMonitors(void)
|
||||||
}
|
}
|
||||||
#endif /*_GLFW_HAS_XRANDR*/
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return monitorList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -280,7 +280,8 @@ void _glfwInitJoysticks(void);
|
||||||
void _glfwTerminateJoysticks(void);
|
void _glfwTerminateJoysticks(void);
|
||||||
|
|
||||||
// Monitors
|
// Monitors
|
||||||
void _glfwInitMonitors(void);
|
_GLFWmonitor* _glfwCreateMonitors(void);
|
||||||
|
_GLFWmonitor* _glfwDestroyMonitor(_GLFWmonitor* monitor);
|
||||||
|
|
||||||
// Unicode support
|
// Unicode support
|
||||||
long _glfwKeySym2Unicode(KeySym keysym);
|
long _glfwKeySym2Unicode(KeySym keysym);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user