mirror of
https://github.com/glfw/glfw.git
synced 2025-10-03 13:20:58 +00:00
Merge 2d1a98136e
into c85294e0b2
This commit is contained in:
commit
1ba0ee78e7
1
.gitignore
vendored
1
.gitignore
vendored
@ -25,6 +25,7 @@ src/glfw_config.h
|
|||||||
src/glfw3.pc
|
src/glfw3.pc
|
||||||
src/glfwConfig.cmake
|
src/glfwConfig.cmake
|
||||||
src/glfwConfigVersion.cmake
|
src/glfwConfigVersion.cmake
|
||||||
|
install_manifest.txt
|
||||||
|
|
||||||
# Compiled binaries
|
# Compiled binaries
|
||||||
src/libglfw.so
|
src/libglfw.so
|
||||||
|
@ -55,7 +55,8 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* The available context API macros are:
|
* The available context API macros are:
|
||||||
* * `GLFW_EXPOSE_NATIVE_WGL`
|
* * `GLFW_EXPOSE_NATIVE_WGL`
|
||||||
* * `GLFW_EXPOSE_NATIVE_NSGL`
|
* * `GLFW_EXPOSE_NATIVE_NSGL` (OSX, ObjC required to do anything useful)
|
||||||
|
* * `GLFW_EXPOSE_NATIVE_CGL`
|
||||||
* * `GLFW_EXPOSE_NATIVE_GLX`
|
* * `GLFW_EXPOSE_NATIVE_GLX`
|
||||||
* * `GLFW_EXPOSE_NATIVE_EGL`
|
* * `GLFW_EXPOSE_NATIVE_EGL`
|
||||||
*
|
*
|
||||||
@ -94,6 +95,8 @@ extern "C" {
|
|||||||
/* WGL is declared by windows.h */
|
/* WGL is declared by windows.h */
|
||||||
#elif defined(GLFW_EXPOSE_NATIVE_NSGL)
|
#elif defined(GLFW_EXPOSE_NATIVE_NSGL)
|
||||||
/* NSGL is declared by Cocoa.h */
|
/* NSGL is declared by Cocoa.h */
|
||||||
|
#elif defined(GLFW_EXPOSE_NATIVE_CGL)
|
||||||
|
#include <OpenGL/OpenGL.h>
|
||||||
#elif defined(GLFW_EXPOSE_NATIVE_GLX)
|
#elif defined(GLFW_EXPOSE_NATIVE_GLX)
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
#elif defined(GLFW_EXPOSE_NATIVE_EGL)
|
#elif defined(GLFW_EXPOSE_NATIVE_EGL)
|
||||||
@ -151,6 +154,14 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
|
|||||||
GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
|
GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_CGL)
|
||||||
|
/*! @brief Returns the `CGLContextObj` of the specified window.
|
||||||
|
* @return The `CGLContextObj` of the specified window.
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI CGLContextObj glfwGetCGLContext(GLFWwindow* window);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_X11)
|
#if defined(GLFW_EXPOSE_NATIVE_X11)
|
||||||
/*! @brief Returns the `Display` used by GLFW.
|
/*! @brief Returns the `Display` used by GLFW.
|
||||||
* @return The `Display` used by GLFW.
|
* @return The `Display` used by GLFW.
|
||||||
|
@ -38,6 +38,68 @@
|
|||||||
#include <ApplicationServices/ApplicationServices.h>
|
#include <ApplicationServices/ApplicationServices.h>
|
||||||
|
|
||||||
|
|
||||||
|
// Returns the io_service_t corresponding to a CG display ID, or 0 on failure.
|
||||||
|
// The io_service_t should be released with IOObjectRelease when not needed.
|
||||||
|
//
|
||||||
|
static io_service_t IOServicePortFromCGDisplayID(CGDirectDisplayID displayID)
|
||||||
|
{
|
||||||
|
io_iterator_t iter;
|
||||||
|
io_service_t serv, servicePort = 0;
|
||||||
|
|
||||||
|
CFMutableDictionaryRef matching = IOServiceMatching("IODisplayConnect");
|
||||||
|
|
||||||
|
// releases matching for us
|
||||||
|
kern_return_t err = IOServiceGetMatchingServices(kIOMasterPortDefault,
|
||||||
|
matching,
|
||||||
|
&iter);
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((serv = IOIteratorNext(iter)) != 0)
|
||||||
|
{
|
||||||
|
CFDictionaryRef info;
|
||||||
|
CFIndex vendorID, productID;
|
||||||
|
CFNumberRef vendorIDRef, productIDRef;
|
||||||
|
Boolean success;
|
||||||
|
|
||||||
|
info = IODisplayCreateInfoDictionary(serv,
|
||||||
|
kIODisplayOnlyPreferredName);
|
||||||
|
|
||||||
|
vendorIDRef = CFDictionaryGetValue(info,
|
||||||
|
CFSTR(kDisplayVendorID));
|
||||||
|
productIDRef = CFDictionaryGetValue(info,
|
||||||
|
CFSTR(kDisplayProductID));
|
||||||
|
|
||||||
|
success = CFNumberGetValue(vendorIDRef, kCFNumberCFIndexType,
|
||||||
|
&vendorID);
|
||||||
|
success &= CFNumberGetValue(productIDRef, kCFNumberCFIndexType,
|
||||||
|
&productID);
|
||||||
|
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
CFRelease(info);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CGDisplayVendorNumber(displayID) != vendorID ||
|
||||||
|
CGDisplayModelNumber(displayID) != productID)
|
||||||
|
{
|
||||||
|
CFRelease(info);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// we're a match
|
||||||
|
servicePort = serv;
|
||||||
|
CFRelease(info);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
IOObjectRelease(iter);
|
||||||
|
return servicePort;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the name of the specified display
|
// Get the name of the specified display
|
||||||
//
|
//
|
||||||
static char* getDisplayName(CGDirectDisplayID displayID)
|
static char* getDisplayName(CGDirectDisplayID displayID)
|
||||||
@ -47,8 +109,17 @@ static char* getDisplayName(CGDirectDisplayID displayID)
|
|||||||
CFStringRef value;
|
CFStringRef value;
|
||||||
CFIndex size;
|
CFIndex size;
|
||||||
|
|
||||||
info = IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID),
|
io_service_t serv = IOServicePortFromCGDisplayID(displayID);
|
||||||
|
if (!serv)
|
||||||
|
{
|
||||||
|
return strdup("Unknown");
|
||||||
|
}
|
||||||
|
|
||||||
|
info = IODisplayCreateInfoDictionary(serv,
|
||||||
kIODisplayOnlyPreferredName);
|
kIODisplayOnlyPreferredName);
|
||||||
|
|
||||||
|
IOObjectRelease(serv);
|
||||||
|
|
||||||
names = CFDictionaryGetValue(info, CFSTR(kDisplayProductName));
|
names = CFDictionaryGetValue(info, CFSTR(kDisplayProductName));
|
||||||
|
|
||||||
if (!names || !CFDictionaryGetValueIfPresent(names, CFSTR("en_US"),
|
if (!names || !CFDictionaryGetValueIfPresent(names, CFSTR("en_US"),
|
||||||
@ -56,7 +127,6 @@ static char* getDisplayName(CGDirectDisplayID displayID)
|
|||||||
{
|
{
|
||||||
// This may happen if a desktop Mac is running headless
|
// This may happen if a desktop Mac is running headless
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to retrieve display name");
|
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to retrieve display name");
|
||||||
|
|
||||||
CFRelease(info);
|
CFRelease(info);
|
||||||
return strdup("Unknown");
|
return strdup("Unknown");
|
||||||
}
|
}
|
||||||
@ -71,6 +141,7 @@ static char* getDisplayName(CGDirectDisplayID displayID)
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Check whether the display mode should be included in enumeration
|
// Check whether the display mode should be included in enumeration
|
||||||
//
|
//
|
||||||
static GLboolean modeIsGood(CGDisplayModeRef mode)
|
static GLboolean modeIsGood(CGDisplayModeRef mode)
|
||||||
|
@ -299,3 +299,9 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle)
|
|||||||
return window->nsgl.context;
|
return window->nsgl.context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWAPI CGLContextObj glfwGetCGLContext(GLFWwindow* handle)
|
||||||
|
{
|
||||||
|
NSOpenGLContext* ctx = glfwGetNSGLContext(handle);
|
||||||
|
return [ctx CGLContextObj];
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user