mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 04:54:35 +00:00
Fixed zero refresh rate on some monitors.
This commit is contained in:
parent
99784fb8f0
commit
aab08712dd
@ -356,13 +356,15 @@ if (_GLFW_COCOA AND _GLFW_NSGL)
|
|||||||
find_library(COCOA_FRAMEWORK Cocoa)
|
find_library(COCOA_FRAMEWORK Cocoa)
|
||||||
find_library(IOKIT_FRAMEWORK IOKit)
|
find_library(IOKIT_FRAMEWORK IOKit)
|
||||||
find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation)
|
find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation)
|
||||||
|
find_library(CORE_VIDEO_FRAMEWORK CoreVideo)
|
||||||
list(APPEND glfw_LIBRARIES ${COCOA_FRAMEWORK}
|
list(APPEND glfw_LIBRARIES ${COCOA_FRAMEWORK}
|
||||||
${OPENGL_gl_LIBRARY}
|
${OPENGL_gl_LIBRARY}
|
||||||
${IOKIT_FRAMEWORK}
|
${IOKIT_FRAMEWORK}
|
||||||
${CORE_FOUNDATION_FRAMEWORK})
|
${CORE_FOUNDATION_FRAMEWORK}
|
||||||
|
${CORE_VIDEO_FRAMEWORK})
|
||||||
|
|
||||||
set(GLFW_PKG_DEPS "")
|
set(GLFW_PKG_DEPS "")
|
||||||
set(GLFW_PKG_LIBS "-framework Cocoa -framework OpenGL -framework IOKit -framework CoreFoundation")
|
set(GLFW_PKG_LIBS "-framework Cocoa -framework OpenGL -framework IOKit -framework CoreFoundation -framework CoreVideo")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
|
@ -223,6 +223,7 @@ See the [GLFW documentation](http://www.glfw.org/docs/latest/).
|
|||||||
with Xcode 5
|
with Xcode 5
|
||||||
- [Cocoa] Bugfix: The cursor remained visible if moved onto client area after
|
- [Cocoa] Bugfix: The cursor remained visible if moved onto client area after
|
||||||
having been set to hidden outside it
|
having been set to hidden outside it
|
||||||
|
- [Cocoa] Bugfix: The refresh rate was zero for all modes of certain monitors
|
||||||
- [X11] Added setting of the `WM_CLASS` property to the initial window title
|
- [X11] Added setting of the `WM_CLASS` property to the initial window title
|
||||||
|
|
||||||
|
|
||||||
@ -309,6 +310,7 @@ skills.
|
|||||||
- Matt Sealey
|
- Matt Sealey
|
||||||
- SephiRok
|
- SephiRok
|
||||||
- Steve Sexton
|
- Steve Sexton
|
||||||
|
- Systemcluster
|
||||||
- Dmitri Shuralyov
|
- Dmitri Shuralyov
|
||||||
- Daniel Skorupski
|
- Daniel Skorupski
|
||||||
- Bradley Smith
|
- Bradley Smith
|
||||||
|
@ -189,7 +189,7 @@ If you are using the dynamic library version of GLFW, simply add it to the
|
|||||||
project dependencies.
|
project dependencies.
|
||||||
|
|
||||||
If you are using the static library version of GLFW, add it and the Cocoa,
|
If you are using the static library version of GLFW, add it and the Cocoa,
|
||||||
OpenGL and IOKit frameworks to the project as dependencies.
|
OpenGL, IOKit and CoreVideo frameworks to the project as dependencies.
|
||||||
|
|
||||||
|
|
||||||
@subsection build_link_osx With command-line on OS X
|
@subsection build_link_osx With command-line on OS X
|
||||||
@ -198,7 +198,7 @@ If you do not wish to use pkg-config, you need to add the required frameworks
|
|||||||
and libraries to your command-line using the `-l` and `-framework` switches,
|
and libraries to your command-line using the `-l` and `-framework` switches,
|
||||||
i.e.:
|
i.e.:
|
||||||
|
|
||||||
cc -o myprog myprog.c -lglfw -framework Cocoa -framework OpenGL -framework IOKit
|
cc -o myprog myprog.c -lglfw -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo
|
||||||
|
|
||||||
Note that you do not add the `.framework` extension to a framework when adding
|
Note that you do not add the `.framework` extension to a framework when adding
|
||||||
it from the command-line.
|
it from the command-line.
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include <IOKit/graphics/IOGraphicsLib.h>
|
#include <IOKit/graphics/IOGraphicsLib.h>
|
||||||
|
#include <IOKit/graphics/IOGraphicsLib.h>
|
||||||
|
#include <CoreVideo/CVBase.h>
|
||||||
|
|
||||||
|
|
||||||
// Get the name of the specified display
|
// Get the name of the specified display
|
||||||
@ -94,13 +96,21 @@ static GLboolean modeIsGood(CGDisplayModeRef mode)
|
|||||||
|
|
||||||
// Convert Core Graphics display mode to GLFW video mode
|
// Convert Core Graphics display mode to GLFW video mode
|
||||||
//
|
//
|
||||||
static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode)
|
static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,
|
||||||
|
CVDisplayLinkRef link)
|
||||||
{
|
{
|
||||||
GLFWvidmode result;
|
GLFWvidmode result;
|
||||||
result.width = (int) CGDisplayModeGetWidth(mode);
|
result.width = (int) CGDisplayModeGetWidth(mode);
|
||||||
result.height = (int) CGDisplayModeGetHeight(mode);
|
result.height = (int) CGDisplayModeGetHeight(mode);
|
||||||
result.refreshRate = (int) CGDisplayModeGetRefreshRate(mode);
|
result.refreshRate = (int) CGDisplayModeGetRefreshRate(mode);
|
||||||
|
|
||||||
|
if (result.refreshRate == 0)
|
||||||
|
{
|
||||||
|
const CVTime time = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link);
|
||||||
|
if (!(time.flags & kCVTimeIsIndefinite))
|
||||||
|
result.refreshRate = (int) (time.timeScale / (double) time.timeValue);
|
||||||
|
}
|
||||||
|
|
||||||
CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
|
CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
|
||||||
|
|
||||||
if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) == 0)
|
if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) == 0)
|
||||||
@ -334,6 +344,9 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
|||||||
CFArrayRef modes;
|
CFArrayRef modes;
|
||||||
CFIndex count, i;
|
CFIndex count, i;
|
||||||
GLFWvidmode* result;
|
GLFWvidmode* result;
|
||||||
|
CVDisplayLinkRef link;
|
||||||
|
|
||||||
|
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
|
||||||
|
|
||||||
modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
|
modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
|
||||||
count = CFArrayGetCount(modes);
|
count = CFArrayGetCount(modes);
|
||||||
@ -348,21 +361,28 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
|||||||
mode = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
|
mode = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
|
||||||
if (modeIsGood(mode))
|
if (modeIsGood(mode))
|
||||||
{
|
{
|
||||||
result[*found] = vidmodeFromCGDisplayMode(mode);
|
result[*found] = vidmodeFromCGDisplayMode(mode, link);
|
||||||
(*found)++;
|
(*found)++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CFRelease(modes);
|
CFRelease(modes);
|
||||||
|
|
||||||
|
CVDisplayLinkRelease(link);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
|
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
|
||||||
{
|
{
|
||||||
CGDisplayModeRef displayMode;
|
CGDisplayModeRef displayMode;
|
||||||
|
CVDisplayLinkRef link;
|
||||||
|
|
||||||
|
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
|
||||||
|
|
||||||
displayMode = CGDisplayCopyDisplayMode(monitor->ns.displayID);
|
displayMode = CGDisplayCopyDisplayMode(monitor->ns.displayID);
|
||||||
*mode = vidmodeFromCGDisplayMode(displayMode);
|
*mode = vidmodeFromCGDisplayMode(displayMode, link);
|
||||||
CGDisplayModeRelease(displayMode);
|
CGDisplayModeRelease(displayMode);
|
||||||
|
|
||||||
|
CVDisplayLinkRelease(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user