36 #ifndef EDS_ROTATEDMODE 37 #define EDS_ROTATEDMODE 0x00000004 39 #ifndef DISPLAY_DEVICE_ACTIVE 40 #define DISPLAY_DEVICE_ACTIVE 0x00000001 61 ZeroMemory(&dm,
sizeof(dm));
62 dm.dmSize =
sizeof(DEVMODEW);
63 dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL |
65 dm.dmPelsWidth = best->
width;
66 dm.dmPelsHeight = best->
height;
70 if (dm.dmBitsPerPel < 15 || dm.dmBitsPerPel >= 24)
73 if (ChangeDisplaySettingsExW(monitor->win32.adapterName,
77 NULL) != DISP_CHANGE_SUCCESSFUL)
83 monitor->win32.modeChanged = GL_TRUE;
91 if (monitor->win32.modeChanged)
93 ChangeDisplaySettingsExW(monitor->win32.adapterName,
94 NULL, NULL, CDS_FULLSCREEN, NULL);
95 monitor->win32.modeChanged = GL_FALSE;
108 DWORD adapterIndex, displayIndex;
112 for (adapterIndex = 0; ; adapterIndex++)
114 DISPLAY_DEVICEW adapter;
116 ZeroMemory(&adapter,
sizeof(DISPLAY_DEVICEW));
117 adapter.cb =
sizeof(DISPLAY_DEVICEW);
119 if (!EnumDisplayDevicesW(NULL, adapterIndex, &adapter, 0))
125 for (displayIndex = 0; ; displayIndex++)
127 DISPLAY_DEVICEW display;
132 ZeroMemory(&display,
sizeof(DISPLAY_DEVICEW));
133 display.cb =
sizeof(DISPLAY_DEVICEW);
135 if (!EnumDisplayDevicesW(adapter.DeviceName, displayIndex, &display, 0))
142 "Win32: Failed to convert string to UTF-8");
146 dc = CreateDCW(L
"DISPLAY", adapter.DeviceName, NULL, NULL);
149 GetDeviceCaps(dc, HORZSIZE),
150 GetDeviceCaps(dc, VERTSIZE));
155 if (adapter.StateFlags & DISPLAY_DEVICE_MODESPRUNED)
156 monitor->win32.modesPruned = GL_TRUE;
158 wcscpy(monitor->win32.adapterName, adapter.DeviceName);
159 wcscpy(monitor->win32.displayName, display.DeviceName);
161 WideCharToMultiByte(CP_UTF8, 0,
162 adapter.DeviceName, -1,
163 monitor->win32.publicAdapterName,
164 sizeof(monitor->win32.publicAdapterName),
167 WideCharToMultiByte(CP_UTF8, 0,
168 display.DeviceName, -1,
169 monitor->win32.publicDisplayName,
170 sizeof(monitor->win32.publicDisplayName),
174 monitors = realloc(monitors,
sizeof(
_GLFWmonitor*) * found);
175 monitors[found - 1] = monitor;
177 if (adapter.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE &&
191 return wcscmp(first->win32.displayName, second->win32.displayName) == 0;
197 ZeroMemory(&settings,
sizeof(DEVMODEW));
198 settings.dmSize =
sizeof(DEVMODEW);
200 EnumDisplaySettingsExW(monitor->win32.adapterName,
201 ENUM_CURRENT_SETTINGS,
206 *xpos = settings.dmPosition.x;
208 *ypos = settings.dmPosition.y;
213 int modeIndex = 0,
size = 0;
224 ZeroMemory(&dm,
sizeof(DEVMODEW));
225 dm.dmSize =
sizeof(DEVMODEW);
227 if (!EnumDisplaySettingsW(monitor->win32.adapterName, modeIndex, &dm))
233 if (dm.dmBitsPerPel < 15)
236 mode.
width = dm.dmPelsWidth;
237 mode.
height = dm.dmPelsHeight;
244 for (i = 0; i < *
count; i++)
254 if (monitor->win32.modesPruned)
257 if (ChangeDisplaySettingsExW(monitor->win32.adapterName,
261 NULL) != DISP_CHANGE_SUCCESSFUL)
278 result[*count - 1] =
mode;
288 ZeroMemory(&dm,
sizeof(DEVMODEW));
289 dm.dmSize =
sizeof(DEVMODEW);
291 EnumDisplaySettingsW(monitor->win32.adapterName, ENUM_CURRENT_SETTINGS, &dm);
293 mode->
width = dm.dmPelsWidth;
294 mode->
height = dm.dmPelsHeight;
307 dc = CreateDCW(L
"DISPLAY", monitor->win32.adapterName, NULL, NULL);
308 GetDeviceGammaRamp(dc, values);
313 memcpy(ramp->
red, values + 0, 256 *
sizeof(
unsigned short));
314 memcpy(ramp->
green, values + 256, 256 *
sizeof(
unsigned short));
315 memcpy(ramp->
blue, values + 512, 256 *
sizeof(
unsigned short));
323 if (ramp->
size != 256)
326 "Win32: Gamma ramp size must be 256");
330 memcpy(values + 0, ramp->
red, 256 *
sizeof(
unsigned short));
331 memcpy(values + 256, ramp->
green, 256 *
sizeof(
unsigned short));
332 memcpy(values + 512, ramp->
blue, 256 *
sizeof(
unsigned short));
334 dc = CreateDCW(L
"DISPLAY", monitor->win32.adapterName, NULL, NULL);
335 SetDeviceGammaRamp(dc, values);
348 return monitor->win32.publicAdapterName;
355 return monitor->win32.publicDisplayName;
#define DISPLAY_DEVICE_ACTIVE
GLboolean _glfwSetVideoMode(_GLFWmonitor *monitor, const GLFWvidmode *desired)
struct GLFWmonitor GLFWmonitor
Opaque monitor object.
#define _GLFW_SWAP_POINTERS(x, y)
#define _GLFW_REQUIRE_INIT_OR_RETURN(x)
typedef GLboolean(APIENTRYP PFNGLISQUERYPROC)(GLuint id)
#define GLFW_PLATFORM_ERROR
A platform-specific error occurred that does not match any of the more specific categories.
GLuint GLuint GLsizei count
void _glfwRestoreVideoMode(_GLFWmonitor *monitor)
void _glfwSplitBPP(int bpp, int *red, int *green, int *blue)
Splits a color depth into red, green and blue bit depths.
_GLFWmonitor * _glfwAllocMonitor(const char *name, int widthMM, int heightMM)
Allocates and returns a monitor object with the specified name and dimensions.
typedef HDC(WINAPI *PFNWGLGETCURRENTREADDCARBPROC)(void)
GLFWAPI const char * glfwGetWin32Monitor(GLFWmonitor *handle)
void _glfwAllocGammaArrays(GLFWgammaramp *ramp, unsigned int size)
GLenum GLsizei GLsizei GLint * values
GLuint const GLchar * name
GLFWAPI const char * glfwGetWin32Adapter(GLFWmonitor *handle)
int _glfwCompareVideoModes(const GLFWvidmode *first, const GLFWvidmode *second)
Performs lexical comparison between two GLFWvidmode structures.
void _glfwInputError(int error, const char *format,...)
Notifies shared code of an error.
const GLFWvidmode * _glfwChooseVideoMode(_GLFWmonitor *monitor, const GLFWvidmode *desired)
char * _glfwCreateUTF8FromWideString(const WCHAR *source)