mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 02:38:52 -05:00
Reshuffling, formatting and shortening.
This commit is contained in:
parent
29a4eca87d
commit
9738728298
|
@ -469,10 +469,22 @@ extern "C" {
|
||||||
/* Gamma ramps */
|
/* Gamma ramps */
|
||||||
#define GLFW_GAMMA_RAMP_SIZE 256
|
#define GLFW_GAMMA_RAMP_SIZE 256
|
||||||
|
|
||||||
|
/* Monitor constants */
|
||||||
|
#define GLFW_MONITOR_CONNECTED 0
|
||||||
|
#define GLFW_MONITOR_DISCONNECTED 1
|
||||||
|
#define GLFW_MONITOR_NAME 0
|
||||||
|
#define GLFW_MONITOR_PHYSICAL_WIDTH 1
|
||||||
|
#define GLFW_MONITOR_PHYSICAL_HEIGHT 2
|
||||||
|
#define GLFW_MONITOR_SCREEN_POS_X 3
|
||||||
|
#define GLFW_MONITOR_SCREEN_POS_Y 4
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* Typedefs
|
* Typedefs
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
|
/* Monitor handle type */
|
||||||
|
typedef void* GLFWmonitor;
|
||||||
|
|
||||||
/* Window handle type */
|
/* Window handle type */
|
||||||
typedef void* GLFWwindow;
|
typedef void* GLFWwindow;
|
||||||
|
|
||||||
|
@ -490,6 +502,7 @@ typedef void (* GLFWkeyfun)(GLFWwindow,int,int);
|
||||||
typedef void (* GLFWcharfun)(GLFWwindow,int);
|
typedef void (* GLFWcharfun)(GLFWwindow,int);
|
||||||
typedef void* (* GLFWmallocfun)(size_t);
|
typedef void* (* GLFWmallocfun)(size_t);
|
||||||
typedef void (* GLFWfreefun)(void*);
|
typedef void (* GLFWfreefun)(void*);
|
||||||
|
typedef void (* GLFWmonitordevicefun)(GLFWmonitor,int);
|
||||||
|
|
||||||
/* The video mode structure used by glfwGetVideoModes */
|
/* The video mode structure used by glfwGetVideoModes */
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -539,33 +552,18 @@ GLFWAPI int glfwGetError(void);
|
||||||
GLFWAPI const char* glfwErrorString(int error);
|
GLFWAPI const char* glfwErrorString(int error);
|
||||||
GLFWAPI void glfwSetErrorCallback(GLFWerrorfun cbfun);
|
GLFWAPI void glfwSetErrorCallback(GLFWerrorfun cbfun);
|
||||||
|
|
||||||
/* Monitor constants */
|
|
||||||
#define GLFW_MONITOR_INVALID_HANDLE (NULL)
|
|
||||||
#define GLFW_MONITOR_CONNECTED 0
|
|
||||||
#define GLFW_MONITOR_DISCONNECTED 1
|
|
||||||
#define GLFW_MONITOR_PARAM_S_NAME 0
|
|
||||||
#define GLFW_MONITOR_PARAM_I_PHYS_WIDTH 1
|
|
||||||
#define GLFW_MONITOR_PARAM_I_PHYS_HEIGHT 2
|
|
||||||
#define GLFW_MONITOR_PARAM_I_SCREEN_X_POS 3
|
|
||||||
#define GLFW_MONITOR_PARAM_I_SCREEN_Y_POS 4
|
|
||||||
|
|
||||||
/* Monitor types */
|
|
||||||
typedef struct _GLFWmonitor* GLFWmonitor;
|
|
||||||
typedef void (* GLFWmonitordevicefun)(GLFWmonitor,int); /* connect / disconnect */
|
|
||||||
|
|
||||||
/* Monitor callback registration */
|
/* Monitor callback registration */
|
||||||
GLFWAPI void glfwSetMonitorDeviceCallback(GLFWmonitordevicefun cbfun);
|
GLFWAPI void glfwSetMonitorDeviceCallback(GLFWmonitordevicefun cbfun);
|
||||||
|
|
||||||
/* Monitor attributes */
|
/* Monitor attributes */
|
||||||
GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor monitor, void* pointer);
|
GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor monitor, void* pointer);
|
||||||
GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor monitor);
|
GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor monitor);
|
||||||
GLFWAPI int glfwGetMonitorIntegerParam(GLFWmonitor monitor, int param);
|
GLFWAPI int glfwGetMonitorParam(GLFWmonitor monitor, int param);
|
||||||
GLFWAPI const char* glfwGetMonitorStringParam(GLFWmonitor monitor, int param);
|
GLFWAPI const char* glfwGetMonitorString(GLFWmonitor monitor, int param);
|
||||||
|
|
||||||
/* Monitor discovery */
|
/* Monitor discovery */
|
||||||
GLFWAPI GLFWmonitor glfwGetNextMonitor(GLFWmonitor iterator);
|
GLFWAPI GLFWmonitor glfwGetNextMonitor(GLFWmonitor iterator);
|
||||||
|
|
||||||
|
|
||||||
/* Video mode functions */
|
/* Video mode functions */
|
||||||
GLFWAPI int glfwGetVideoModes(GLFWmonitor monitor, GLFWvidmode* list, int maxcount);
|
GLFWAPI int glfwGetVideoModes(GLFWmonitor monitor, GLFWvidmode* list, int maxcount);
|
||||||
GLFWAPI void glfwGetDesktopMode(GLFWvidmode* mode);
|
GLFWAPI void glfwGetDesktopMode(GLFWvidmode* mode);
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
add_definitions(-DWINVER=0x0501)
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
if(CYGWIN)
|
if(CYGWIN)
|
||||||
|
|
||||||
# These lines are intended to remove the --export-all-symbols
|
# These lines are intended to remove the --export-all-symbols
|
||||||
|
|
|
@ -100,9 +100,10 @@ void _glfwSplitBPP(int bpp, int* red, int* green, int* blue)
|
||||||
// Get a list of available video modes
|
// Get a list of available video modes
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI int glfwGetVideoModes(GLFWmonitor monitor, GLFWvidmode* list, int maxcount)
|
GLFWAPI int glfwGetVideoModes(GLFWmonitor handle, GLFWvidmode* list, int maxcount)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
|
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||||
|
|
||||||
if (!_glfwInitialized)
|
if (!_glfwInitialized)
|
||||||
{
|
{
|
||||||
|
@ -110,9 +111,10 @@ GLFWAPI int glfwGetVideoModes(GLFWmonitor monitor, GLFWvidmode* list, int maxcou
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monitor == GLFW_MONITOR_INVALID_HANDLE)
|
if (monitor == NULL)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_INVALID_VALUE, "Monitor handle is invalid.");
|
_glfwSetError(GLFW_INVALID_VALUE,
|
||||||
|
"glfwGetVideoModes: Invalid monitor handle");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -225,13 +225,13 @@ struct _GLFWmonitor
|
||||||
|
|
||||||
void* userPointer;
|
void* userPointer;
|
||||||
|
|
||||||
char* deviceName;
|
char* name;
|
||||||
// physical dimensions in millimeters.
|
// physical dimensions in millimeters.
|
||||||
int physicalWidth;
|
int physicalWidth;
|
||||||
int physicalHeight;
|
int physicalHeight;
|
||||||
// logical orientation of the screen on the desktop
|
// logical orientation of the screen on the desktop
|
||||||
int screenXPosition;
|
int screenX;
|
||||||
int screenYPosition;
|
int screenY;
|
||||||
|
|
||||||
// These are defined in the current port's platform.h
|
// These are defined in the current port's platform.h
|
||||||
_GLFW_PLATFORM_MONITOR_STATE;
|
_GLFW_PLATFORM_MONITOR_STATE;
|
||||||
|
@ -301,7 +301,7 @@ void _glfwPlatformEnableSystemKeys(_GLFWwindow* window);
|
||||||
void _glfwPlatformDisableSystemKeys(_GLFWwindow* window);
|
void _glfwPlatformDisableSystemKeys(_GLFWwindow* window);
|
||||||
|
|
||||||
// Fullscreen
|
// Fullscreen
|
||||||
int _glfwPlatformGetVideoModes(GLFWmonitor monitor, GLFWvidmode* list, int maxcount);
|
int _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, GLFWvidmode* list, int maxcount);
|
||||||
void _glfwPlatformGetDesktopMode(GLFWvidmode* mode);
|
void _glfwPlatformGetDesktopMode(GLFWvidmode* mode);
|
||||||
|
|
||||||
// Gamma ramp
|
// Gamma ramp
|
||||||
|
|
|
@ -31,81 +31,102 @@
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
////// GLFW public API //////
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Get a list of connected monitors
|
// Iterate through connected monitors
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI GLFWmonitor glfwGetNextMonitor(GLFWmonitor iterator)
|
GLFWAPI GLFWmonitor glfwGetNextMonitor(GLFWmonitor handle)
|
||||||
{
|
{
|
||||||
GLFWmonitor result = GLFW_MONITOR_INVALID_HANDLE;
|
_GLFWmonitor* iterator = (_GLFWmonitor*) handle;
|
||||||
|
_GLFWmonitor* result = NULL;
|
||||||
|
|
||||||
if (!_glfwInitialized)
|
if (!_glfwInitialized)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iterator == GLFW_MONITOR_INVALID_HANDLE)
|
if (iterator == NULL)
|
||||||
{
|
|
||||||
result = _glfwLibrary.monitorListHead;
|
result = _glfwLibrary.monitorListHead;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
result = iterator->next;
|
result = iterator->next;
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI int glfwGetMonitorIntegerParam(GLFWmonitor monitor, int param)
|
|
||||||
|
//========================================================================
|
||||||
|
// Get monitor parameter
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
GLFWAPI int glfwGetMonitorParam(GLFWmonitor handle, int param)
|
||||||
{
|
{
|
||||||
|
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||||
|
|
||||||
if (!_glfwInitialized)
|
if (!_glfwInitialized)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monitor == GLFW_MONITOR_INVALID_HANDLE)
|
if (monitor == NULL)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_INVALID_VALUE, "Monitor handle is invalid.");
|
_glfwSetError(GLFW_INVALID_VALUE,
|
||||||
|
"glfwGetMonitorParam: Invalid monitor handle");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(param)
|
switch (param)
|
||||||
{
|
{
|
||||||
case GLFW_MONITOR_PARAM_I_PHYS_WIDTH:
|
case GLFW_MONITOR_PHYSICAL_WIDTH:
|
||||||
return monitor->physicalWidth;
|
return monitor->physicalWidth;
|
||||||
case GLFW_MONITOR_PARAM_I_PHYS_HEIGHT:
|
case GLFW_MONITOR_PHYSICAL_HEIGHT:
|
||||||
return monitor->physicalHeight;
|
return monitor->physicalHeight;
|
||||||
case GLFW_MONITOR_PARAM_I_SCREEN_X_POS:
|
case GLFW_MONITOR_SCREEN_POS_X:
|
||||||
return monitor->screenXPosition;
|
return monitor->screenX;
|
||||||
case GLFW_MONITOR_PARAM_I_SCREEN_Y_POS:
|
case GLFW_MONITOR_SCREEN_POS_Y:
|
||||||
return monitor->screenYPosition;
|
return monitor->screenY;
|
||||||
default:
|
|
||||||
_glfwSetError(GLFW_INVALID_ENUM, "Param represents not a valid integer monitor attribute.");
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_glfwSetError(GLFW_INVALID_ENUM,
|
||||||
|
"glfwGetMonitorParam: Invalid enum value for 'param' parameter");
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI const char* glfwGetMonitorStringParam(GLFWmonitor monitor, int param)
|
|
||||||
|
//========================================================================
|
||||||
|
// Get monitor string
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
GLFWAPI const char* glfwGetMonitorString(GLFWmonitor handle, int param)
|
||||||
{
|
{
|
||||||
|
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||||
|
|
||||||
if (!_glfwInitialized)
|
if (!_glfwInitialized)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monitor == GLFW_MONITOR_INVALID_HANDLE)
|
if (monitor == NULL)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_INVALID_VALUE, "monitor handle is invalid.");
|
_glfwSetError(GLFW_INVALID_VALUE,
|
||||||
|
"glfwGetMonitorString: Invalid monitor handle");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(param)
|
switch (param)
|
||||||
{
|
{
|
||||||
case GLFW_MONITOR_PARAM_S_NAME:
|
case GLFW_MONITOR_NAME:
|
||||||
return monitor->deviceName;
|
return monitor->name;
|
||||||
default:
|
|
||||||
_glfwSetError(GLFW_INVALID_ENUM, "Param represents not a valid string monitor attribute.");
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_glfwSetError(GLFW_INVALID_ENUM,
|
||||||
|
"glfwGetMonitorString: Invalid enum value for 'param' parameter");
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,7 @@ void _glfwRestoreVideoMode(void)
|
||||||
// Get a list of available video modes
|
// Get a list of available video modes
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
int _glfwPlatformGetVideoModes(GLFWmonitor monitor, GLFWvidmode* list, int maxcount)
|
int _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, GLFWvidmode* list, int maxcount)
|
||||||
{
|
{
|
||||||
DEVMODE deviceMode;
|
DEVMODE deviceMode;
|
||||||
DWORD deviceModeNum;
|
DWORD deviceModeNum;
|
||||||
|
@ -197,14 +197,18 @@ int _glfwPlatformGetVideoModes(GLFWmonitor monitor, GLFWvidmode* list, int maxc
|
||||||
vidModes = NULL;
|
vidModes = NULL;
|
||||||
vidModesCount = 0;
|
vidModesCount = 0;
|
||||||
|
|
||||||
while (EnumDisplaySettings(monitor->Win32.DeviceName, deviceModeNum, &deviceMode) && (!list || (vidModesCount < maxcount)))
|
for (;;)
|
||||||
{
|
{
|
||||||
|
if (!EnumDisplaySettings(monitor->Win32.name, deviceModeNum, &deviceMode))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (vidModesCount >= maxcount)
|
||||||
|
break;
|
||||||
|
|
||||||
deviceModeNum++;
|
deviceModeNum++;
|
||||||
|
|
||||||
if (deviceMode.dmBitsPerPel < 15)
|
if (deviceMode.dmBitsPerPel < 15)
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
vidMode.height = deviceMode.dmPelsHeight;
|
vidMode.height = deviceMode.dmPelsHeight;
|
||||||
vidMode.width = deviceMode.dmPelsWidth;
|
vidMode.width = deviceMode.dmPelsWidth;
|
||||||
|
@ -216,9 +220,7 @@ int _glfwPlatformGetVideoModes(GLFWmonitor monitor, GLFWvidmode* list, int maxc
|
||||||
|
|
||||||
// skip duplicates.
|
// skip duplicates.
|
||||||
if (vidModes && bsearch(&vidMode, vidModes, vidModesCount, sizeof(GLFWvidmode), _glfwCompareVideoModes))
|
if (vidModes && bsearch(&vidMode, vidModes, vidModesCount, sizeof(GLFWvidmode), _glfwCompareVideoModes))
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
vidModes = realloc(vidModes, sizeof(GLFWvidmode) * ++vidModesCount);
|
vidModes = realloc(vidModes, sizeof(GLFWvidmode) * ++vidModesCount);
|
||||||
memcpy(vidModes + (vidModesCount - 1), &vidMode, sizeof(GLFWvidmode));
|
memcpy(vidModes + (vidModesCount - 1), &vidMode, sizeof(GLFWvidmode));
|
||||||
|
@ -227,9 +229,7 @@ int _glfwPlatformGetVideoModes(GLFWmonitor monitor, GLFWvidmode* list, int maxc
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list && maxcount)
|
if (list && maxcount)
|
||||||
{
|
|
||||||
memcpy(list, vidModes, sizeof(GLFWvidmode) * min(vidModesCount, maxcount));
|
memcpy(list, vidModes, sizeof(GLFWvidmode) * min(vidModesCount, maxcount));
|
||||||
}
|
|
||||||
|
|
||||||
free(vidModes);
|
free(vidModes);
|
||||||
|
|
||||||
|
|
|
@ -33,12 +33,20 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
// The MinGW package for Debian lacks this
|
||||||
|
#ifndef EDS_ROTATEDMODE
|
||||||
|
#define EDS_ROTATEDMODE 0x00000004
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
_GLFWmonitor** _glfwCreateMonitor(_GLFWmonitor** current, DISPLAY_DEVICE* adapter, DISPLAY_DEVICE* monitor, DEVMODE* setting)
|
_GLFWmonitor** _glfwCreateMonitor(_GLFWmonitor** current,
|
||||||
|
DISPLAY_DEVICE* adapter,
|
||||||
|
DISPLAY_DEVICE* monitor,
|
||||||
|
DEVMODE* setting)
|
||||||
{
|
{
|
||||||
HDC dc = NULL;
|
HDC dc = NULL;
|
||||||
|
|
||||||
|
@ -52,14 +60,14 @@ _GLFWmonitor** _glfwCreateMonitor(_GLFWmonitor** current, DISPLAY_DEVICE* adapte
|
||||||
|
|
||||||
DeleteDC(dc);
|
DeleteDC(dc);
|
||||||
|
|
||||||
(*current)->deviceName = _glfwMalloc(strlen(monitor->DeviceName) + 1);
|
(*current)->name = _glfwMalloc(strlen(monitor->DeviceName) + 1);
|
||||||
memcpy((*current)->deviceName, monitor->DeviceName, strlen(monitor->DeviceName) + 1);
|
memcpy((*current)->name, monitor->DeviceName, strlen(monitor->DeviceName) + 1);
|
||||||
(*current)->deviceName[strlen(monitor->DeviceName)] = '\0';
|
(*current)->name[strlen(monitor->DeviceName)] = '\0';
|
||||||
|
|
||||||
(*current)->screenXPosition = setting->dmPosition.x;
|
(*current)->screenX = setting->dmPosition.x;
|
||||||
(*current)->screenYPosition = setting->dmPosition.y;
|
(*current)->screenY = setting->dmPosition.y;
|
||||||
|
|
||||||
memcpy((*current)->Win32.DeviceName, adapter->DeviceName, 32);
|
memcpy((*current)->Win32.name, adapter->DeviceName, 32);
|
||||||
return &((*current)->next);
|
return &((*current)->next);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +77,7 @@ _GLFWmonitor* _glfwDestroyMonitor(_GLFWmonitor* monitor)
|
||||||
|
|
||||||
result = monitor->next;
|
result = monitor->next;
|
||||||
|
|
||||||
_glfwFree(monitor->deviceName);
|
_glfwFree(monitor->name);
|
||||||
_glfwFree(monitor);
|
_glfwFree(monitor);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -96,14 +104,15 @@ void _glfwInitMonitors(void)
|
||||||
setting.dmSize = sizeof(DEVMODE);
|
setting.dmSize = sizeof(DEVMODE);
|
||||||
settingNum = 0;
|
settingNum = 0;
|
||||||
|
|
||||||
while(EnumDisplayDevices(NULL, adapterNum++, &adapter, 0))
|
while (EnumDisplayDevices(NULL, adapterNum++, &adapter, 0))
|
||||||
{
|
{
|
||||||
if(adapter.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER)
|
if (adapter.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER)
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
EnumDisplaySettingsEx(adapter.DeviceName, ENUM_CURRENT_SETTINGS, &setting, EDS_ROTATEDMODE);
|
EnumDisplaySettingsEx(adapter.DeviceName,
|
||||||
|
ENUM_CURRENT_SETTINGS,
|
||||||
|
&setting,
|
||||||
|
EDS_ROTATEDMODE);
|
||||||
|
|
||||||
EnumDisplayDevices(adapter.DeviceName, 0, &monitor, 0);
|
EnumDisplayDevices(adapter.DeviceName, 0, &monitor, 0);
|
||||||
|
|
||||||
|
@ -113,7 +122,7 @@ void _glfwInitMonitors(void)
|
||||||
|
|
||||||
void _glfwTerminateMonitors(void)
|
void _glfwTerminateMonitors(void)
|
||||||
{
|
{
|
||||||
while(_glfwLibrary.monitorListHead)
|
while (_glfwLibrary.monitorListHead)
|
||||||
_glfwLibrary.monitorListHead = _glfwDestroyMonitor(_glfwLibrary.monitorListHead);
|
_glfwLibrary.monitorListHead = _glfwDestroyMonitor(_glfwLibrary.monitorListHead);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -316,7 +316,8 @@ typedef struct _GLFWlibraryWin32
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
typedef struct _GLFWmonitorWin32
|
typedef struct _GLFWmonitorWin32
|
||||||
{
|
{
|
||||||
char DeviceName[32];
|
char name[32];
|
||||||
|
|
||||||
} _GLFWmonitorWin32;
|
} _GLFWmonitorWin32;
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
|
@ -33,9 +33,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
void showMouseCursor(_GLFWwindow* window);
|
|
||||||
void captureMouseCursor(_GLFWwindow* window);
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Convert BPP to RGB bits based on "best guess"
|
// Convert BPP to RGB bits based on "best guess"
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
@ -148,6 +145,48 @@ static void setForegroundWindow(HWND hWnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Hide mouse cursor (lock it)
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
static void hideMouseCursor(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
ShowCursor(FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Show mouse cursor (unlock it)
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
static void showMouseCursor(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
// Un-capture cursor
|
||||||
|
ReleaseCapture();
|
||||||
|
|
||||||
|
// Release the cursor from the window
|
||||||
|
ClipCursor(NULL);
|
||||||
|
|
||||||
|
ShowCursor(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Capture mouse cursor
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
static void captureMouseCursor(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
RECT ClipWindowRect;
|
||||||
|
|
||||||
|
// Clip cursor to the window
|
||||||
|
if (GetWindowRect(window->Win32.handle, &ClipWindowRect))
|
||||||
|
ClipCursor(&ClipWindowRect);
|
||||||
|
|
||||||
|
// Capture cursor to user window
|
||||||
|
SetCapture(window->Win32.handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Returns the specified attribute of the specified pixel format
|
// Returns the specified attribute of the specified pixel format
|
||||||
// NOTE: Do not call this unless we have found WGL_ARB_pixel_format
|
// NOTE: Do not call this unless we have found WGL_ARB_pixel_format
|
||||||
|
@ -1848,50 +1887,6 @@ void _glfwPlatformWaitEvents(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Hide mouse cursor (lock it)
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
void hideMouseCursor(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
ShowCursor(FALSE);
|
|
||||||
|
|
||||||
captureMouseCursor(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Show mouse cursor (unlock it)
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
void showMouseCursor(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
// Un-capture cursor
|
|
||||||
ReleaseCapture();
|
|
||||||
|
|
||||||
// Release the cursor from the window
|
|
||||||
ClipCursor(NULL);
|
|
||||||
|
|
||||||
ShowCursor(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Capture mouse cursor
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
static void captureMouseCursor(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
RECT ClipWindowRect;
|
|
||||||
|
|
||||||
// Clip cursor to the window
|
|
||||||
if (GetWindowRect(window->Win32.handle, &ClipWindowRect))
|
|
||||||
ClipCursor(&ClipWindowRect);
|
|
||||||
|
|
||||||
// Capture cursor to user window
|
|
||||||
SetCapture(window->Win32.handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Set physical mouse cursor position
|
// Set physical mouse cursor position
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
|
@ -344,7 +344,7 @@ int _glfwCompareResolution(const void* left, const void* right)
|
||||||
// List available video modes
|
// List available video modes
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
int _glfwPlatformGetVideoModes(GLFWmonitor monitor, GLFWvidmode* list, int maxcount)
|
int _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, GLFWvidmode* list, int maxcount)
|
||||||
{
|
{
|
||||||
int count, k, l, r, g, b, rgba, gl;
|
int count, k, l, r, g, b, rgba, gl;
|
||||||
int depth, screen;
|
int depth, screen;
|
||||||
|
|
|
@ -38,8 +38,9 @@
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#if defined (_GLFW_HAS_XRANDR)
|
_GLFWmonitor** _glfwCreateMonitor(_GLFWmonitor** current,
|
||||||
_GLFWmonitor** _glfwCreateMonitor(_GLFWmonitor** current, XRROutputInfo* outputInfo, XRRCrtcInfo* crtcInfo)
|
XRROutputInfo* outputInfo,
|
||||||
|
XRRCrtcInfo* crtcInfo)
|
||||||
{
|
{
|
||||||
*current = _glfwMalloc(sizeof(_GLFWmonitor));
|
*current = _glfwMalloc(sizeof(_GLFWmonitor));
|
||||||
memset(*current, 0, sizeof(_GLFWmonitor));
|
memset(*current, 0, sizeof(_GLFWmonitor));
|
||||||
|
@ -47,17 +48,16 @@ _GLFWmonitor** _glfwCreateMonitor(_GLFWmonitor** current, XRROutputInfo* outputI
|
||||||
(*current)->physicalWidth = outputInfo->mm_width;
|
(*current)->physicalWidth = outputInfo->mm_width;
|
||||||
(*current)->physicalHeight = outputInfo->mm_height;
|
(*current)->physicalHeight = outputInfo->mm_height;
|
||||||
|
|
||||||
(*current)->deviceName = _glfwMalloc(strlen(outputInfo->name) + 1);
|
(*current)->name = _glfwMalloc(strlen(outputInfo->name) + 1);
|
||||||
memcpy((*current)->deviceName, outputInfo->name, strlen(outputInfo->name) + 1);
|
memcpy((*current)->name, outputInfo->name, strlen(outputInfo->name) + 1);
|
||||||
(*current)->deviceName[strlen(outputInfo->name)] = '\0';
|
(*current)->name[strlen(outputInfo->name)] = '\0';
|
||||||
|
|
||||||
(*current)->screenXPosition = crtcInfo->x;
|
(*current)->screenX = crtcInfo->x;
|
||||||
(*current)->screenYPosition = crtcInfo->y;
|
(*current)->screenY = crtcInfo->y;
|
||||||
|
|
||||||
(*current)->X11.output = outputInfo;
|
(*current)->X11.output = outputInfo;
|
||||||
return &((*current)->next);
|
return &((*current)->next);
|
||||||
}
|
}
|
||||||
#endif /*_GLFW_HAS_XRANDR*/
|
|
||||||
|
|
||||||
_GLFWmonitor* _glfwDestroyMonitor(_GLFWmonitor* monitor)
|
_GLFWmonitor* _glfwDestroyMonitor(_GLFWmonitor* monitor)
|
||||||
{
|
{
|
||||||
|
@ -69,7 +69,7 @@ _GLFWmonitor* _glfwDestroyMonitor(_GLFWmonitor* monitor)
|
||||||
XRRFreeOutputInfo(monitor->X11.output);
|
XRRFreeOutputInfo(monitor->X11.output);
|
||||||
#endif /*_GLFW_HAS_XRANDR*/
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
|
|
||||||
_glfwFree(monitor->deviceName);
|
_glfwFree(monitor->name);
|
||||||
_glfwFree(monitor);
|
_glfwFree(monitor);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -79,7 +79,7 @@ void _glfwInitMonitors(void)
|
||||||
{
|
{
|
||||||
_glfwLibrary.monitorListHead = NULL;
|
_glfwLibrary.monitorListHead = NULL;
|
||||||
|
|
||||||
if(_glfwLibrary.X11.RandR.available == GL_TRUE)
|
if (_glfwLibrary.X11.RandR.available)
|
||||||
{
|
{
|
||||||
#if defined (_GLFW_HAS_XRANDR)
|
#if defined (_GLFW_HAS_XRANDR)
|
||||||
XRRScreenResources* resources;
|
XRRScreenResources* resources;
|
||||||
|
@ -91,7 +91,7 @@ void _glfwInitMonitors(void)
|
||||||
resources = XRRGetScreenResources(_glfwLibrary.X11.display,
|
resources = XRRGetScreenResources(_glfwLibrary.X11.display,
|
||||||
_glfwLibrary.X11.root);
|
_glfwLibrary.X11.root);
|
||||||
|
|
||||||
for(outputIDX = 0; outputIDX < resources->noutput; outputIDX++)
|
for (outputIDX = 0; outputIDX < resources->noutput; outputIDX++)
|
||||||
{
|
{
|
||||||
// physical device
|
// physical device
|
||||||
XRROutputInfo* outputInfo = NULL;
|
XRROutputInfo* outputInfo = NULL;
|
||||||
|
@ -103,11 +103,11 @@ void _glfwInitMonitors(void)
|
||||||
resources,
|
resources,
|
||||||
resources->outputs[outputIDX]);
|
resources->outputs[outputIDX]);
|
||||||
|
|
||||||
if(outputInfo->connection == RR_Connected)
|
if (outputInfo->connection == RR_Connected)
|
||||||
{
|
{
|
||||||
for(crtcIDX = 0; crtcIDX < outputInfo->ncrtc; crtcIDX++)
|
for (crtcIDX = 0; crtcIDX < outputInfo->ncrtc; crtcIDX++)
|
||||||
{
|
{
|
||||||
if(outputInfo->crtc == outputInfo->crtcs[crtcIDX])
|
if (outputInfo->crtc == outputInfo->crtcs[crtcIDX])
|
||||||
{
|
{
|
||||||
crtcInfo = XRRGetCrtcInfo(_glfwLibrary.X11.display,
|
crtcInfo = XRRGetCrtcInfo(_glfwLibrary.X11.display,
|
||||||
resources,
|
resources,
|
||||||
|
@ -128,7 +128,7 @@ void _glfwInitMonitors(void)
|
||||||
|
|
||||||
void _glfwTerminateMonitors(void)
|
void _glfwTerminateMonitors(void)
|
||||||
{
|
{
|
||||||
while(_glfwLibrary.monitorListHead)
|
while (_glfwLibrary.monitorListHead)
|
||||||
_glfwLibrary.monitorListHead = _glfwDestroyMonitor(_glfwLibrary.monitorListHead);
|
_glfwLibrary.monitorListHead = _glfwDestroyMonitor(_glfwLibrary.monitorListHead);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -252,8 +252,10 @@ typedef struct _GLFWmonitorX11
|
||||||
{
|
{
|
||||||
#if defined(_GLFW_HAS_XRANDR)
|
#if defined(_GLFW_HAS_XRANDR)
|
||||||
XRROutputInfo* output;
|
XRROutputInfo* output;
|
||||||
#endif /*_GLFW_HAS_XRANDR*/
|
#else
|
||||||
int dummy;
|
int dummy;
|
||||||
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
|
|
||||||
} _GLFWmonitorX11;
|
} _GLFWmonitorX11;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ static void print_mode(GLFWvidmode* mode)
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
GLFWmonitor monitorHandle;
|
GLFWmonitor monitor;
|
||||||
GLFWvidmode dtmode, modes[400];
|
GLFWvidmode dtmode, modes[400];
|
||||||
int modecount, i;
|
int modecount, i;
|
||||||
|
|
||||||
|
@ -33,29 +33,30 @@ int main(void)
|
||||||
printf("Desktop mode: ");
|
printf("Desktop mode: ");
|
||||||
print_mode(&dtmode);
|
print_mode(&dtmode);
|
||||||
|
|
||||||
monitorHandle = GLFW_MONITOR_INVALID_HANDLE;
|
monitor = NULL;
|
||||||
|
|
||||||
while( GLFW_MONITOR_INVALID_HANDLE != ( monitorHandle = glfwGetNextMonitor( monitorHandle )))
|
while ((monitor = glfwGetNextMonitor(monitor)))
|
||||||
{
|
{
|
||||||
printf( "Monitor name: %s\n"
|
printf("Monitor name: %s\n"
|
||||||
"Physical dimensions: %dmm x %dmm\n"
|
"Physical dimensions: %dmm x %dmm\n"
|
||||||
"Logical position: (%d,%d)\n",
|
"Logical position: (%d,%d)\n",
|
||||||
glfwGetMonitorStringParam( monitorHandle, GLFW_MONITOR_PARAM_S_NAME ),
|
glfwGetMonitorString(monitor, GLFW_MONITOR_NAME),
|
||||||
glfwGetMonitorIntegerParam( monitorHandle, GLFW_MONITOR_PARAM_I_PHYS_WIDTH ),
|
glfwGetMonitorParam(monitor, GLFW_MONITOR_PHYSICAL_WIDTH),
|
||||||
glfwGetMonitorIntegerParam( monitorHandle, GLFW_MONITOR_PARAM_I_PHYS_HEIGHT ),
|
glfwGetMonitorParam(monitor, GLFW_MONITOR_PHYSICAL_HEIGHT),
|
||||||
glfwGetMonitorIntegerParam( monitorHandle, GLFW_MONITOR_PARAM_I_SCREEN_X_POS ),
|
glfwGetMonitorParam(monitor, GLFW_MONITOR_SCREEN_POS_X),
|
||||||
glfwGetMonitorIntegerParam( monitorHandle, GLFW_MONITOR_PARAM_I_SCREEN_Y_POS )
|
glfwGetMonitorParam(monitor, GLFW_MONITOR_SCREEN_POS_Y));
|
||||||
);
|
|
||||||
// List available video modes
|
// List available video modes
|
||||||
modecount = glfwGetVideoModes(monitorHandle, modes, sizeof(modes) / sizeof(GLFWvidmode));
|
modecount = glfwGetVideoModes(monitor, modes, sizeof(modes) / sizeof(GLFWvidmode));
|
||||||
printf( "Available modes:\n" );
|
printf("Available modes:\n");
|
||||||
for( i = 0; i < modecount; i ++ )
|
|
||||||
|
for (i = 0; i < modecount; i++)
|
||||||
{
|
{
|
||||||
printf("%3i: ", i);
|
printf("%3i: ", i);
|
||||||
print_mode(modes + i);
|
print_mode(modes + i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glfwTerminate();
|
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user