mirror of
https://github.com/glfw/glfw.git
synced 2026-09-18 22:55:46 +00:00
Replaced glfwGetDesktopMode with glfwGetVideoMode.
This commit is contained in:
+10
-4
@@ -167,6 +167,8 @@ GLboolean _glfwSetVideoMode(int* width, int* height, int* bpp, int* refreshRate)
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
_glfwLibrary.NS.previousMode = CGDisplayCopyDisplayMode(CGMainDisplayID());
|
||||
|
||||
CGDisplayCapture(CGMainDisplayID());
|
||||
CGDisplaySetDisplayMode(CGMainDisplayID(), bestMode, NULL);
|
||||
|
||||
@@ -182,7 +184,7 @@ GLboolean _glfwSetVideoMode(int* width, int* height, int* bpp, int* refreshRate)
|
||||
void _glfwRestoreVideoMode(void)
|
||||
{
|
||||
CGDisplaySetDisplayMode(CGMainDisplayID(),
|
||||
_glfwLibrary.NS.desktopMode,
|
||||
_glfwLibrary.NS.previousMode,
|
||||
NULL);
|
||||
|
||||
CGDisplayRelease(CGMainDisplayID());
|
||||
@@ -227,11 +229,15 @@ GLFWvidmode* _glfwPlatformGetVideoModes(int* found)
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Get the desktop video mode
|
||||
// Get the current video mode for the specified monitor
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformGetDesktopMode(GLFWvidmode *mode)
|
||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
|
||||
{
|
||||
*mode = vidmodeFromCGDisplayMode(_glfwLibrary.NS.desktopMode);
|
||||
CGDisplayModeRef displayMode;
|
||||
|
||||
displayMode = CGDisplayCopyDisplayMode(CGMainDisplayID());
|
||||
*mode = vidmodeFromCGDisplayMode(displayMode);
|
||||
CGDisplayModeRelease(displayMode);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,8 +92,6 @@ int _glfwPlatformInit(void)
|
||||
|
||||
changeToResourcesDirectory();
|
||||
|
||||
_glfwLibrary.NS.desktopMode = CGDisplayCopyDisplayMode(CGMainDisplayID());
|
||||
|
||||
// Save the original gamma ramp
|
||||
_glfwLibrary.originalRampSize = CGDisplayGammaTableCapacity(CGMainDisplayID());
|
||||
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
|
||||
@@ -132,8 +130,6 @@ int _glfwPlatformTerminate(void)
|
||||
if (_glfwLibrary.rampChanged)
|
||||
_glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp);
|
||||
|
||||
CGDisplayModeRelease(_glfwLibrary.NS.desktopMode);
|
||||
|
||||
[NSApp setDelegate:nil];
|
||||
[_glfwLibrary.NS.delegate release];
|
||||
_glfwLibrary.NS.delegate = nil;
|
||||
|
||||
@@ -90,7 +90,7 @@ typedef struct _GLFWlibraryNS
|
||||
double resolution;
|
||||
} timer;
|
||||
|
||||
CGDisplayModeRef desktopMode;
|
||||
CGDisplayModeRef previousMode;
|
||||
CGEventSourceRef eventSource;
|
||||
id delegate;
|
||||
id autoreleasePool;
|
||||
|
||||
+6
-5
@@ -150,11 +150,13 @@ GLFWAPI GLFWvidmode* glfwGetVideoModes(GLFWmonitor handle, int* count)
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Get the desktop video mode
|
||||
// Get the current video mode for the specified monitor
|
||||
//========================================================================
|
||||
|
||||
GLFWAPI void glfwGetDesktopMode(GLFWvidmode* mode)
|
||||
GLFWAPI void glfwGetVideoMode(GLFWmonitor handle, GLFWvidmode* mode)
|
||||
{
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
@@ -163,11 +165,10 @@ GLFWAPI void glfwGetDesktopMode(GLFWvidmode* mode)
|
||||
|
||||
if (mode == NULL)
|
||||
{
|
||||
_glfwSetError(GLFW_INVALID_VALUE,
|
||||
"glfwGetDesktopMode: Parameter 'mode' cannot be NULL");
|
||||
_glfwSetError(GLFW_INVALID_VALUE, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
_glfwPlatformGetDesktopMode(mode);
|
||||
_glfwPlatformGetVideoMode(monitor, mode);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -286,7 +286,7 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode);
|
||||
|
||||
// Video mode support
|
||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count);
|
||||
void _glfwPlatformGetDesktopMode(GLFWvidmode* mode);
|
||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode);
|
||||
|
||||
// Gamma ramp support
|
||||
void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp);
|
||||
|
||||
+13
-5
@@ -268,18 +268,26 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Get the desktop video mode
|
||||
// Get the current video mode for the specified monitor
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformGetDesktopMode(GLFWvidmode* mode)
|
||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
{
|
||||
DEVMODE dm;
|
||||
WCHAR* deviceName;
|
||||
|
||||
// Get desktop display mode
|
||||
deviceName = _glfwCreateWideStringFromUTF8(monitor->Win32.name);
|
||||
if (!deviceName)
|
||||
{
|
||||
_glfwSetError(GLFW_PLATFORM_ERROR, "Win32: Failed to convert device name");
|
||||
return;
|
||||
}
|
||||
|
||||
ZeroMemory(&dm, sizeof(DEVMODE));
|
||||
dm.dmSize = sizeof(DEVMODE);
|
||||
EnumDisplaySettings(NULL, ENUM_REGISTRY_SETTINGS, &dm);
|
||||
|
||||
// Return desktop mode parameters
|
||||
EnumDisplaySettings(deviceName, ENUM_REGISTRY_SETTINGS, &dm);
|
||||
|
||||
mode->width = dm.dmPelsWidth;
|
||||
mode->height = dm.dmPelsHeight;
|
||||
_glfwSplitBPP(dm.dmBitsPerPel,
|
||||
|
||||
+9
-31
@@ -514,40 +514,18 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Get the desktop video mode
|
||||
// Get the current video mode for the specified monitor
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformGetDesktopMode(GLFWvidmode* mode)
|
||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
{
|
||||
int bpp;
|
||||
_glfwSplitBPP(DefaultDepth(_glfwLibrary.X11.display,
|
||||
_glfwLibrary.X11.screen),
|
||||
&mode->redBits, &mode->greenBits, &mode->blueBits);
|
||||
|
||||
// Get and split display depth
|
||||
bpp = DefaultDepth(_glfwLibrary.X11.display, _glfwLibrary.X11.screen);
|
||||
_glfwSplitBPP(bpp, &mode->redBits, &mode->greenBits, &mode->blueBits);
|
||||
|
||||
if (_glfwLibrary.X11.FS.modeChanged)
|
||||
{
|
||||
if (_glfwLibrary.X11.RandR.available)
|
||||
{
|
||||
#if defined(_GLFW_HAS_XRANDR)
|
||||
mode->width = _glfwLibrary.X11.FS.oldWidth;
|
||||
mode->height = _glfwLibrary.X11.FS.oldHeight;
|
||||
#endif /*_GLFW_HAS_XRANDR*/
|
||||
}
|
||||
else if (_glfwLibrary.X11.VidMode.available)
|
||||
{
|
||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
||||
mode->width = _glfwLibrary.X11.FS.oldMode.hdisplay;
|
||||
mode->height = _glfwLibrary.X11.FS.oldMode.vdisplay;
|
||||
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mode->width = DisplayWidth(_glfwLibrary.X11.display,
|
||||
_glfwLibrary.X11.screen);
|
||||
mode->height = DisplayHeight(_glfwLibrary.X11.display,
|
||||
_glfwLibrary.X11.screen);
|
||||
}
|
||||
mode->width = DisplayWidth(_glfwLibrary.X11.display,
|
||||
_glfwLibrary.X11.screen);
|
||||
mode->height = DisplayHeight(_glfwLibrary.X11.display,
|
||||
_glfwLibrary.X11.screen);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user