add option to remove titlebar

This commit is contained in:
Kasper de Bruin 2024-01-19 13:58:24 +01:00
parent 8e6c8d7eff
commit f906f7ae3f
8 changed files with 3093 additions and 3192 deletions

File diff suppressed because it is too large Load Diff

View File

@ -169,8 +169,7 @@ extern "C" {
* of the specified monitor, or `NULL` if an [error](@ref error_handling) * of the specified monitor, or `NULL` if an [error](@ref error_handling)
* occurred. * occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* GLFW_PLATFORM_UNAVAILABLE.
* *
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
@ -187,8 +186,7 @@ GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
* `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an * `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* GLFW_PLATFORM_UNAVAILABLE.
* *
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
@ -204,8 +202,7 @@ GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
* @return The `HWND` of the specified window, or `NULL` if an * @return The `HWND` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* GLFW_PLATFORM_UNAVAILABLE.
* *
* @remark The `HDC` associated with the window can be queried with the * @remark The `HDC` associated with the window can be queried with the
* [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc) * [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
@ -231,8 +228,8 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
* @return The `HGLRC` of the specified window, or `NULL` if an * @return The `HGLRC` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_NO_WINDOW_CONTEXT. * GLFW_NOT_INITIALIZED.
* *
* @remark The `HDC` associated with the window can be queried with the * @remark The `HDC` associated with the window can be queried with the
* [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc) * [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
@ -258,8 +255,7 @@ GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
* @return The `CGDirectDisplayID` of the specified monitor, or * @return The `CGDirectDisplayID` of the specified monitor, or
* `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred. * `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* GLFW_PLATFORM_UNAVAILABLE.
* *
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
@ -275,8 +271,7 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
* @return The `NSWindow` of the specified window, or `nil` if an * @return The `NSWindow` of the specified window, or `nil` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* GLFW_PLATFORM_UNAVAILABLE.
* *
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
@ -294,8 +289,8 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
* @return The `NSOpenGLContext` of the specified window, or `nil` if an * @return The `NSOpenGLContext` of the specified window, or `nil` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_NO_WINDOW_CONTEXT. * GLFW_NOT_INITIALIZED.
* *
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
@ -313,8 +308,7 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
* @return The `Display` used by GLFW, or `NULL` if an * @return The `Display` used by GLFW, or `NULL` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* GLFW_PLATFORM_UNAVAILABLE.
* *
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
@ -330,8 +324,7 @@ GLFWAPI Display* glfwGetX11Display(void);
* @return The `RRCrtc` of the specified monitor, or `None` if an * @return The `RRCrtc` of the specified monitor, or `None` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* GLFW_PLATFORM_UNAVAILABLE.
* *
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
@ -347,8 +340,7 @@ GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
* @return The `RROutput` of the specified monitor, or `None` if an * @return The `RROutput` of the specified monitor, or `None` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* GLFW_PLATFORM_UNAVAILABLE.
* *
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
@ -364,8 +356,7 @@ GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
* @return The `Window` of the specified window, or `None` if an * @return The `Window` of the specified window, or `None` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* GLFW_PLATFORM_UNAVAILABLE.
* *
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
@ -380,8 +371,8 @@ GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
* *
* @param[in] string A UTF-8 encoded string. * @param[in] string A UTF-8 encoded string.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR. * GLFW_PLATFORM_ERROR.
* *
* @pointer_lifetime The specified string is copied before this function * @pointer_lifetime The specified string is copied before this function
* returns. * returns.
@ -406,8 +397,8 @@ GLFWAPI void glfwSetX11SelectionString(const char* string);
* @return The contents of the selection as a UTF-8 encoded string, or `NULL` * @return The contents of the selection as a UTF-8 encoded string, or `NULL`
* if an [error](@ref error_handling) occurred. * if an [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR. * GLFW_PLATFORM_ERROR.
* *
* @pointer_lifetime The returned string is allocated and freed by GLFW. You * @pointer_lifetime The returned string is allocated and freed by GLFW. You
* should not free it yourself. It is valid until the next call to @ref * should not free it yourself. It is valid until the next call to @ref
@ -433,8 +424,8 @@ GLFWAPI const char* glfwGetX11SelectionString(void);
* @return The `GLXContext` of the specified window, or `NULL` if an * @return The `GLXContext` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_UNAVAILABLE. * GLFW_NOT_INITIALIZED.
* *
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
@ -450,8 +441,8 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
* @return The `GLXWindow` of the specified window, or `None` if an * @return The `GLXWindow` of the specified window, or `None` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_UNAVAILABLE. * GLFW_NOT_INITIALIZED.
* *
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
@ -469,8 +460,7 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window);
* @return The `struct wl_display*` used by GLFW, or `NULL` if an * @return The `struct wl_display*` used by GLFW, or `NULL` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* GLFW_PLATFORM_UNAVAILABLE.
* *
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
@ -486,8 +476,7 @@ GLFWAPI struct wl_display* glfwGetWaylandDisplay(void);
* @return The `struct wl_output*` of the specified monitor, or `NULL` if an * @return The `struct wl_output*` of the specified monitor, or `NULL` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* GLFW_PLATFORM_UNAVAILABLE.
* *
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
@ -503,8 +492,7 @@ GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
* @return The main `struct wl_surface*` of the specified window, or `NULL` if * @return The main `struct wl_surface*` of the specified window, or `NULL` if
* an [error](@ref error_handling) occurred. * an [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* GLFW_PLATFORM_UNAVAILABLE.
* *
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
@ -541,8 +529,8 @@ GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
* @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an * @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NO_WINDOW_CONTEXT. * GLFW_NOT_INITIALIZED.
* *
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
@ -558,8 +546,8 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
* @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an * @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NO_WINDOW_CONTEXT. * GLFW_NOT_INITIALIZED.
* *
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
@ -584,8 +572,8 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NO_WINDOW_CONTEXT. * GLFW_NOT_INITIALIZED.
* *
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
@ -608,8 +596,8 @@ GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NO_WINDOW_CONTEXT. * GLFW_NOT_INITIALIZED.
* *
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
@ -625,8 +613,8 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height
* @return The `OSMesaContext` of the specified window, or `NULL` if an * @return The `OSMesaContext` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NO_WINDOW_CONTEXT. * GLFW_NOT_INITIALIZED.
* *
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.

View File

@ -59,9 +59,7 @@ static void changeToResourcesDirectory(void)
if (!CFURLGetFileSystemRepresentation(resourcesURL, if (!CFURLGetFileSystemRepresentation(resourcesURL,
true, true,
(UInt8*) resourcesPath, (UInt8 *)resourcesPath, MAXPATHLEN)) {
MAXPATHLEN))
{
CFRelease(resourcesURL); CFRelease(resourcesURL);
return; return;
} }
@ -76,12 +74,10 @@ static void changeToResourcesDirectory(void)
// could go away at any moment, lots of stuff that really should be // could go away at any moment, lots of stuff that really should be
// localize(d|able), etc. Add a nib to save us this horror. // localize(d|able), etc. Add a nib to save us this horror.
// //
static void createMenuBar(void) static void createMenuBar(void) {
{ NSString *appName = nil;
NSString* appName = nil; NSDictionary *bundleInfo = [[NSBundle mainBundle] infoDictionary];
NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary]; NSString *nameKeys[] = {
NSString* nameKeys[] =
{
@"CFBundleDisplayName", @"CFBundleDisplayName",
@"CFBundleName", @"CFBundleName",
@"CFBundleExecutable", @"CFBundleExecutable",
@ -89,43 +85,39 @@ static void createMenuBar(void)
// Try to figure out what the calling application is called // Try to figure out what the calling application is called
for (size_t i = 0; i < sizeof(nameKeys) / sizeof(nameKeys[0]); i++) for (size_t i = 0; i < sizeof(nameKeys) / sizeof(nameKeys[0]); i++) {
{
id name = bundleInfo[nameKeys[i]]; id name = bundleInfo[nameKeys[i]];
if (name && if (name && [name isKindOfClass:[NSString class]] &&
[name isKindOfClass:[NSString class]] && ![name isEqualToString:@""]) {
![name isEqualToString:@""])
{
appName = name; appName = name;
break; break;
} }
} }
if (!appName) if (!appName) {
{ char **progname = _NSGetProgname();
char** progname = _NSGetProgname();
if (progname && *progname) if (progname && *progname)
appName = @(*progname); appName = @(*progname);
else else
appName = @"GLFW Application"; appName = @"GLFW Application";
} }
NSMenu* bar = [[NSMenu alloc] init]; NSMenu *bar = [[NSMenu alloc] init];
[NSApp setMainMenu:bar]; [NSApp setMainMenu:bar];
NSMenuItem* appMenuItem = NSMenuItem *appMenuItem = [bar addItemWithTitle:@""
[bar addItemWithTitle:@"" action:NULL keyEquivalent:@""]; action:NULL
NSMenu* appMenu = [[NSMenu alloc] init]; keyEquivalent:@""];
NSMenu *appMenu = [[NSMenu alloc] init];
[appMenuItem setSubmenu:appMenu]; [appMenuItem setSubmenu:appMenu];
[appMenu addItemWithTitle:[NSString stringWithFormat:@"About %@", appName] [appMenu addItemWithTitle:[NSString stringWithFormat:@"About %@", appName]
action:@selector(orderFrontStandardAboutPanel:) action:@selector(orderFrontStandardAboutPanel:)
keyEquivalent:@""]; keyEquivalent:@""];
[appMenu addItem:[NSMenuItem separatorItem]]; [appMenu addItem:[NSMenuItem separatorItem]];
NSMenu* servicesMenu = [[NSMenu alloc] init]; NSMenu *servicesMenu = [[NSMenu alloc] init];
[NSApp setServicesMenu:servicesMenu]; [NSApp setServicesMenu:servicesMenu];
[[appMenu addItemWithTitle:@"Services" [[appMenu addItemWithTitle:@"Services" action:NULL
action:NULL
keyEquivalent:@""] setSubmenu:servicesMenu]; keyEquivalent:@""] setSubmenu:servicesMenu];
[servicesMenu release]; [servicesMenu release];
[appMenu addItem:[NSMenuItem separatorItem]]; [appMenu addItem:[NSMenuItem separatorItem]];
@ -135,7 +127,8 @@ static void createMenuBar(void)
[[appMenu addItemWithTitle:@"Hide Others" [[appMenu addItemWithTitle:@"Hide Others"
action:@selector(hideOtherApplications:) action:@selector(hideOtherApplications:)
keyEquivalent:@"h"] keyEquivalent:@"h"]
setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand]; setKeyEquivalentModifierMask:NSEventModifierFlagOption |
NSEventModifierFlagCommand];
[appMenu addItemWithTitle:@"Show All" [appMenu addItemWithTitle:@"Show All"
action:@selector(unhideAllApplications:) action:@selector(unhideAllApplications:)
keyEquivalent:@""]; keyEquivalent:@""];
@ -144,10 +137,11 @@ static void createMenuBar(void)
action:@selector(terminate:) action:@selector(terminate:)
keyEquivalent:@"q"]; keyEquivalent:@"q"];
NSMenuItem* windowMenuItem = NSMenuItem *windowMenuItem = [bar addItemWithTitle:@""
[bar addItemWithTitle:@"" action:NULL keyEquivalent:@""]; action:NULL
keyEquivalent:@""];
[bar release]; [bar release];
NSMenu* windowMenu = [[NSMenu alloc] initWithTitle:@"Window"]; NSMenu *windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
[NSApp setWindowsMenu:windowMenu]; [NSApp setWindowsMenu:windowMenu];
[windowMenuItem setSubmenu:windowMenu]; [windowMenuItem setSubmenu:windowMenu];
@ -167,7 +161,8 @@ static void createMenuBar(void)
[[windowMenu addItemWithTitle:@"Enter Full Screen" [[windowMenu addItemWithTitle:@"Enter Full Screen"
action:@selector(toggleFullScreen:) action:@selector(toggleFullScreen:)
keyEquivalent:@"f"] keyEquivalent:@"f"]
setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand]; setKeyEquivalentModifierMask:NSEventModifierFlagControl |
NSEventModifierFlagCommand];
// Prior to Snow Leopard, we need to use this oddly-named semi-private API // Prior to Snow Leopard, we need to use this oddly-named semi-private API
// to get the application menu working properly. // to get the application menu working properly.
@ -177,8 +172,7 @@ static void createMenuBar(void)
// Create key code translation tables // Create key code translation tables
// //
static void createKeyTables(void) static void createKeyTables(void) {
{
memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes)); memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes));
memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes)); memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes));
@ -297,8 +291,7 @@ static void createKeyTables(void)
_glfw.ns.keycodes[0x43] = GLFW_KEY_KP_MULTIPLY; _glfw.ns.keycodes[0x43] = GLFW_KEY_KP_MULTIPLY;
_glfw.ns.keycodes[0x4E] = GLFW_KEY_KP_SUBTRACT; _glfw.ns.keycodes[0x4E] = GLFW_KEY_KP_SUBTRACT;
for (int scancode = 0; scancode < 256; scancode++) for (int scancode = 0; scancode < 256; scancode++) {
{
// Store the reverse translation for faster key name lookup // Store the reverse translation for faster key name lookup
if (_glfw.ns.keycodes[scancode] >= 0) if (_glfw.ns.keycodes[scancode] >= 0)
_glfw.ns.scancodes[_glfw.ns.keycodes[scancode]] = scancode; _glfw.ns.scancodes[_glfw.ns.keycodes[scancode]] = scancode;
@ -307,28 +300,23 @@ static void createKeyTables(void)
// Retrieve Unicode data for the current keyboard layout // Retrieve Unicode data for the current keyboard layout
// //
static GLFWbool updateUnicodeData(void) static GLFWbool updateUnicodeData(void) {
{ if (_glfw.ns.inputSource) {
if (_glfw.ns.inputSource)
{
CFRelease(_glfw.ns.inputSource); CFRelease(_glfw.ns.inputSource);
_glfw.ns.inputSource = NULL; _glfw.ns.inputSource = NULL;
_glfw.ns.unicodeData = nil; _glfw.ns.unicodeData = nil;
} }
_glfw.ns.inputSource = TISCopyCurrentKeyboardLayoutInputSource(); _glfw.ns.inputSource = TISCopyCurrentKeyboardLayoutInputSource();
if (!_glfw.ns.inputSource) if (!_glfw.ns.inputSource) {
{
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to retrieve keyboard layout input source"); "Cocoa: Failed to retrieve keyboard layout input source");
return GLFW_FALSE; return GLFW_FALSE;
} }
_glfw.ns.unicodeData = _glfw.ns.unicodeData = TISGetInputSourceProperty(
TISGetInputSourceProperty(_glfw.ns.inputSource, _glfw.ns.inputSource, kTISPropertyUnicodeKeyLayoutData);
kTISPropertyUnicodeKeyLayoutData); if (!_glfw.ns.unicodeData) {
if (!_glfw.ns.unicodeData)
{
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to retrieve keyboard layout Unicode data"); "Cocoa: Failed to retrieve keyboard layout Unicode data");
return GLFW_FALSE; return GLFW_FALSE;
@ -339,43 +327,36 @@ static GLFWbool updateUnicodeData(void)
// Load HIToolbox.framework and the TIS symbols we need from it // Load HIToolbox.framework and the TIS symbols we need from it
// //
static GLFWbool initializeTIS(void) static GLFWbool initializeTIS(void) {
{
// This works only because Cocoa has already loaded it properly // This works only because Cocoa has already loaded it properly
_glfw.ns.tis.bundle = _glfw.ns.tis.bundle =
CFBundleGetBundleWithIdentifier(CFSTR("com.apple.HIToolbox")); CFBundleGetBundleWithIdentifier(CFSTR("com.apple.HIToolbox"));
if (!_glfw.ns.tis.bundle) if (!_glfw.ns.tis.bundle) {
{
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to load HIToolbox.framework"); "Cocoa: Failed to load HIToolbox.framework");
return GLFW_FALSE; return GLFW_FALSE;
} }
CFStringRef* kPropertyUnicodeKeyLayoutData = CFStringRef *kPropertyUnicodeKeyLayoutData = CFBundleGetDataPointerForName(
CFBundleGetDataPointerForName(_glfw.ns.tis.bundle, _glfw.ns.tis.bundle, CFSTR("kTISPropertyUnicodeKeyLayoutData"));
CFSTR("kTISPropertyUnicodeKeyLayoutData"));
_glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource = _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource =
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle, CFBundleGetFunctionPointerForName(
_glfw.ns.tis.bundle,
CFSTR("TISCopyCurrentKeyboardLayoutInputSource")); CFSTR("TISCopyCurrentKeyboardLayoutInputSource"));
_glfw.ns.tis.GetInputSourceProperty = _glfw.ns.tis.GetInputSourceProperty = CFBundleGetFunctionPointerForName(
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle, _glfw.ns.tis.bundle, CFSTR("TISGetInputSourceProperty"));
CFSTR("TISGetInputSourceProperty")); _glfw.ns.tis.GetKbdType = CFBundleGetFunctionPointerForName(
_glfw.ns.tis.GetKbdType = _glfw.ns.tis.bundle, CFSTR("LMGetKbdType"));
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
CFSTR("LMGetKbdType"));
if (!kPropertyUnicodeKeyLayoutData || if (!kPropertyUnicodeKeyLayoutData ||
!TISCopyCurrentKeyboardLayoutInputSource || !TISCopyCurrentKeyboardLayoutInputSource || !TISGetInputSourceProperty ||
!TISGetInputSourceProperty || !LMGetKbdType) {
!LMGetKbdType)
{
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to load TIS API symbols"); "Cocoa: Failed to load TIS API symbols");
return GLFW_FALSE; return GLFW_FALSE;
} }
_glfw.ns.tis.kPropertyUnicodeKeyLayoutData = _glfw.ns.tis.kPropertyUnicodeKeyLayoutData = *kPropertyUnicodeKeyLayoutData;
*kPropertyUnicodeKeyLayoutData;
return updateUnicodeData(); return updateUnicodeData();
} }
@ -385,13 +366,11 @@ static GLFWbool initializeTIS(void)
@implementation GLFWHelper @implementation GLFWHelper
- (void)selectedKeyboardInputSourceChanged:(NSObject* )object - (void)selectedKeyboardInputSourceChanged:(NSObject *)object {
{
updateUnicodeData(); updateUnicodeData();
} }
- (void)doNothing:(id)object - (void)doNothing:(id)object {
{
} }
@end // GLFWHelper @end // GLFWHelper
@ -401,18 +380,18 @@ static GLFWbool initializeTIS(void)
@implementation GLFWApplicationDelegate @implementation GLFWApplicationDelegate
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender - (NSApplicationTerminateReply)applicationShouldTerminate:
{ (NSApplication *)sender {
for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next) for (_GLFWwindow *window = _glfw.windowListHead; window;
window = window->next)
_glfwInputWindowCloseRequest(window); _glfwInputWindowCloseRequest(window);
return NSTerminateCancel; return NSTerminateCancel;
} }
- (void)applicationDidChangeScreenParameters:(NSNotification *) notification - (void)applicationDidChangeScreenParameters:(NSNotification *)notification {
{ for (_GLFWwindow *window = _glfw.windowListHead; window;
for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next) window = window->next) {
{
if (window->context.client != GLFW_NO_API) if (window->context.client != GLFW_NO_API)
[window->context.nsgl.object update]; [window->context.nsgl.object update];
} }
@ -420,45 +399,37 @@ static GLFWbool initializeTIS(void)
_glfwPollMonitorsCocoa(); _glfwPollMonitorsCocoa();
} }
- (void)applicationWillFinishLaunching:(NSNotification *)notification - (void)applicationWillFinishLaunching:(NSNotification *)notification {
{ if (_glfw.hints.init.ns.menubar) {
if (_glfw.hints.init.ns.menubar)
{
// Menu bar setup must go between sharedApplication and finishLaunching // Menu bar setup must go between sharedApplication and finishLaunching
// in order to properly emulate the behavior of NSApplicationMain // in order to properly emulate the behavior of NSApplicationMain
if ([[NSBundle mainBundle] pathForResource:@"MainMenu" ofType:@"nib"]) if ([[NSBundle mainBundle] pathForResource:@"MainMenu" ofType:@"nib"]) {
{
[[NSBundle mainBundle] loadNibNamed:@"MainMenu" [[NSBundle mainBundle] loadNibNamed:@"MainMenu"
owner:NSApp owner:NSApp
topLevelObjects:&_glfw.ns.nibObjects]; topLevelObjects:&_glfw.ns.nibObjects];
} } else
else
createMenuBar(); createMenuBar();
} }
} }
- (void)applicationDidFinishLaunching:(NSNotification *)notification - (void)applicationDidFinishLaunching:(NSNotification *)notification {
{
_glfwPostEmptyEventCocoa(); _glfwPostEmptyEventCocoa();
[NSApp stop:nil]; [NSApp stop:nil];
} }
- (void)applicationDidHide:(NSNotification *)notification - (void)applicationDidHide:(NSNotification *)notification {
{
for (int i = 0; i < _glfw.monitorCount; i++) for (int i = 0; i < _glfw.monitorCount; i++)
_glfwRestoreVideoModeCocoa(_glfw.monitors[i]); _glfwRestoreVideoModeCocoa(_glfw.monitors[i]);
} }
@end // GLFWApplicationDelegate @end // GLFWApplicationDelegate
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////// GLFW internal API ////// ////// GLFW internal API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void* _glfwLoadLocalVulkanLoaderCocoa(void) void *_glfwLoadLocalVulkanLoaderCocoa(void) {
{
CFBundleRef bundle = CFBundleGetMainBundle(); CFBundleRef bundle = CFBundleGetMainBundle();
if (!bundle) if (!bundle)
return NULL; return NULL;
@ -469,16 +440,16 @@ void* _glfwLoadLocalVulkanLoaderCocoa(void)
CFURLRef loaderUrl = CFURLCreateCopyAppendingPathComponent( CFURLRef loaderUrl = CFURLCreateCopyAppendingPathComponent(
kCFAllocatorDefault, frameworksUrl, CFSTR("libvulkan.1.dylib"), false); kCFAllocatorDefault, frameworksUrl, CFSTR("libvulkan.1.dylib"), false);
if (!loaderUrl) if (!loaderUrl) {
{
CFRelease(frameworksUrl); CFRelease(frameworksUrl);
return NULL; return NULL;
} }
char path[PATH_MAX]; char path[PATH_MAX];
void* handle = NULL; void *handle = NULL;
if (CFURLGetFileSystemRepresentation(loaderUrl, true, (UInt8*) path, sizeof(path) - 1)) if (CFURLGetFileSystemRepresentation(loaderUrl, true, (UInt8 *)path,
sizeof(path) - 1))
handle = _glfwPlatformLoadModule(path); handle = _glfwPlatformLoadModule(path);
CFRelease(loaderUrl); CFRelease(loaderUrl);
@ -486,15 +457,12 @@ void* _glfwLoadLocalVulkanLoaderCocoa(void)
return handle; return handle;
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////// GLFW platform API ////// ////// GLFW platform API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform) GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform *platform) {
{ const _GLFWplatform cocoa = {
const _GLFWplatform cocoa =
{
GLFW_PLATFORM_COCOA, GLFW_PLATFORM_COCOA,
_glfwInitCocoa, _glfwInitCocoa,
_glfwTerminateCocoa, _glfwTerminateCocoa,
@ -554,6 +522,7 @@ GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform)
_glfwGetWindowOpacityCocoa, _glfwGetWindowOpacityCocoa,
_glfwSetWindowResizableCocoa, _glfwSetWindowResizableCocoa,
_glfwSetWindowDecoratedCocoa, _glfwSetWindowDecoratedCocoa,
_glfwSetWindowTitlebarCocoa,
_glfwSetWindowFloatingCocoa, _glfwSetWindowFloatingCocoa,
_glfwSetWindowOpacityCocoa, _glfwSetWindowOpacityCocoa,
_glfwSetWindowMousePassthroughCocoa, _glfwSetWindowMousePassthroughCocoa,
@ -611,7 +580,7 @@ int _glfwInitCocoa(void)
changeToResourcesDirectory(); changeToResourcesDirectory();
// Press and Hold prevents some keys from emitting repeated characters // Press and Hold prevents some keys from emitting repeated characters
NSDictionary* defaults = @{@"ApplePressAndHoldEnabled":@NO}; NSDictionary *defaults = @{@"ApplePressAndHoldEnabled" : @NO};
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults]; [[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
@ -622,7 +591,8 @@ int _glfwInitCocoa(void)
createKeyTables(); createKeyTables();
_glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState); _glfw.ns.eventSource =
CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
if (!_glfw.ns.eventSource) if (!_glfw.ns.eventSource)
return GLFW_FALSE; return GLFW_FALSE;
@ -645,38 +615,33 @@ int _glfwInitCocoa(void)
} // autoreleasepool } // autoreleasepool
} }
void _glfwTerminateCocoa(void) void _glfwTerminateCocoa(void) {
{
@autoreleasepool { @autoreleasepool {
if (_glfw.ns.inputSource) if (_glfw.ns.inputSource) {
{
CFRelease(_glfw.ns.inputSource); CFRelease(_glfw.ns.inputSource);
_glfw.ns.inputSource = NULL; _glfw.ns.inputSource = NULL;
_glfw.ns.unicodeData = nil; _glfw.ns.unicodeData = nil;
} }
if (_glfw.ns.eventSource) if (_glfw.ns.eventSource) {
{
CFRelease(_glfw.ns.eventSource); CFRelease(_glfw.ns.eventSource);
_glfw.ns.eventSource = NULL; _glfw.ns.eventSource = NULL;
} }
if (_glfw.ns.delegate) if (_glfw.ns.delegate) {
{
[NSApp setDelegate:nil]; [NSApp setDelegate:nil];
[_glfw.ns.delegate release]; [_glfw.ns.delegate release];
_glfw.ns.delegate = nil; _glfw.ns.delegate = nil;
} }
if (_glfw.ns.helper) if (_glfw.ns.helper) {
{
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
removeObserver:_glfw.ns.helper removeObserver:_glfw.ns.helper
name:NSTextInputContextKeyboardSelectionDidChangeNotification name:
NSTextInputContextKeyboardSelectionDidChangeNotification
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter] removeObserver:_glfw.ns.helper];
removeObserver:_glfw.ns.helper];
[_glfw.ns.helper release]; [_glfw.ns.helper release];
_glfw.ns.helper = nil; _glfw.ns.helper = nil;
} }
@ -694,4 +659,3 @@ void _glfwTerminateCocoa(void)
} }
#endif // _GLFW_COCOA #endif // _GLFW_COCOA

View File

@ -243,6 +243,7 @@ GLFWbool _glfwWindowHoveredCocoa(_GLFWwindow* window);
GLFWbool _glfwFramebufferTransparentCocoa(_GLFWwindow* window); GLFWbool _glfwFramebufferTransparentCocoa(_GLFWwindow* window);
void _glfwSetWindowResizableCocoa(_GLFWwindow* window, GLFWbool enabled); void _glfwSetWindowResizableCocoa(_GLFWwindow* window, GLFWbool enabled);
void _glfwSetWindowDecoratedCocoa(_GLFWwindow* window, GLFWbool enabled); void _glfwSetWindowDecoratedCocoa(_GLFWwindow* window, GLFWbool enabled);
void _glfwSetWindowTitlebarCocoa(_GLFWwindow* window, GLFWbool enabled);
void _glfwSetWindowFloatingCocoa(_GLFWwindow* window, GLFWbool enabled); void _glfwSetWindowFloatingCocoa(_GLFWwindow* window, GLFWbool enabled);
float _glfwGetWindowOpacityCocoa(_GLFWwindow* window); float _glfwGetWindowOpacityCocoa(_GLFWwindow* window);
void _glfwSetWindowOpacityCocoa(_GLFWwindow* window, float opacity); void _glfwSetWindowOpacityCocoa(_GLFWwindow* window, float opacity);

File diff suppressed because it is too large Load Diff

View File

@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h" #include "internal.h"

View File

@ -28,21 +28,16 @@
#pragma once #pragma once
#if defined(_GLFW_USE_CONFIG_H) #if defined(_GLFW_USE_CONFIG_H)
#include "glfw_config.h" #include "glfw_config.h"
#endif #endif
#if defined(GLFW_INCLUDE_GLCOREARB) || \ #if defined(GLFW_INCLUDE_GLCOREARB) || defined(GLFW_INCLUDE_ES1) || \
defined(GLFW_INCLUDE_ES1) || \ defined(GLFW_INCLUDE_ES2) || defined(GLFW_INCLUDE_ES3) || \
defined(GLFW_INCLUDE_ES2) || \ defined(GLFW_INCLUDE_ES31) || defined(GLFW_INCLUDE_ES32) || \
defined(GLFW_INCLUDE_ES3) || \ defined(GLFW_INCLUDE_NONE) || defined(GLFW_INCLUDE_GLEXT) || \
defined(GLFW_INCLUDE_ES31) || \ defined(GLFW_INCLUDE_GLU) || defined(GLFW_INCLUDE_VULKAN) || \
defined(GLFW_INCLUDE_ES32) || \
defined(GLFW_INCLUDE_NONE) || \
defined(GLFW_INCLUDE_GLEXT) || \
defined(GLFW_INCLUDE_GLU) || \
defined(GLFW_INCLUDE_VULKAN) || \
defined(GLFW_DLL) defined(GLFW_DLL)
#error "You must not define any header option macros when compiling GLFW" #error "You must not define any header option macros when compiling GLFW"
#endif #endif
#define GLFW_INCLUDE_NONE #define GLFW_INCLUDE_NONE
@ -103,15 +98,15 @@ typedef unsigned int GLenum;
typedef unsigned int GLbitfield; typedef unsigned int GLbitfield;
typedef unsigned char GLubyte; typedef unsigned char GLubyte;
typedef void (APIENTRY * PFNGLCLEARPROC)(GLbitfield); typedef void(APIENTRY *PFNGLCLEARPROC)(GLbitfield);
typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum); typedef const GLubyte *(APIENTRY *PFNGLGETSTRINGPROC)(GLenum);
typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*); typedef void(APIENTRY *PFNGLGETINTEGERVPROC)(GLenum, GLint *);
typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint); typedef const GLubyte *(APIENTRY *PFNGLGETSTRINGIPROC)(GLenum, GLuint);
#if defined(_GLFW_WIN32) #if defined(_GLFW_WIN32)
#define EGLAPIENTRY __stdcall #define EGLAPIENTRY __stdcall
#else #else
#define EGLAPIENTRY #define EGLAPIENTRY
#endif #endif
#define EGL_SUCCESS 0x3000 #define EGL_SUCCESS 0x3000
@ -152,10 +147,10 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint);
#define EGL_EXTENSIONS 0x3055 #define EGL_EXTENSIONS 0x3055
#define EGL_CONTEXT_CLIENT_VERSION 0x3098 #define EGL_CONTEXT_CLIENT_VERSION 0x3098
#define EGL_NATIVE_VISUAL_ID 0x302e #define EGL_NATIVE_VISUAL_ID 0x302e
#define EGL_NO_SURFACE ((EGLSurface) 0) #define EGL_NO_SURFACE ((EGLSurface)0)
#define EGL_NO_DISPLAY ((EGLDisplay) 0) #define EGL_NO_DISPLAY ((EGLDisplay)0)
#define EGL_NO_CONTEXT ((EGLContext) 0) #define EGL_NO_CONTEXT ((EGLContext)0)
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0) #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 #define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 #define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
@ -191,31 +186,40 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint);
typedef int EGLint; typedef int EGLint;
typedef unsigned int EGLBoolean; typedef unsigned int EGLBoolean;
typedef unsigned int EGLenum; typedef unsigned int EGLenum;
typedef void* EGLConfig; typedef void *EGLConfig;
typedef void* EGLContext; typedef void *EGLContext;
typedef void* EGLDisplay; typedef void *EGLDisplay;
typedef void* EGLSurface; typedef void *EGLSurface;
typedef void* EGLNativeDisplayType; typedef void *EGLNativeDisplayType;
typedef void* EGLNativeWindowType; typedef void *EGLNativeWindowType;
// EGL function pointer typedefs // EGL function pointer typedefs
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*); typedef EGLBoolean(EGLAPIENTRY *PFN_eglGetConfigAttrib)(EGLDisplay, EGLConfig,
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*); EGLint, EGLint *);
typedef EGLDisplay (EGLAPIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType); typedef EGLBoolean(EGLAPIENTRY *PFN_eglGetConfigs)(EGLDisplay, EGLConfig *,
typedef EGLint (EGLAPIENTRY * PFN_eglGetError)(void); EGLint, EGLint *);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*); typedef EGLDisplay(EGLAPIENTRY *PFN_eglGetDisplay)(EGLNativeDisplayType);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglTerminate)(EGLDisplay); typedef EGLint(EGLAPIENTRY *PFN_eglGetError)(void);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglBindAPI)(EGLenum); typedef EGLBoolean(EGLAPIENTRY *PFN_eglInitialize)(EGLDisplay, EGLint *,
typedef EGLContext (EGLAPIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*); EGLint *);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface); typedef EGLBoolean(EGLAPIENTRY *PFN_eglTerminate)(EGLDisplay);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext); typedef EGLBoolean(EGLAPIENTRY *PFN_eglBindAPI)(EGLenum);
typedef EGLSurface (EGLAPIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*); typedef EGLContext(EGLAPIENTRY *PFN_eglCreateContext)(EGLDisplay, EGLConfig,
typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext); EGLContext,
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface); const EGLint *);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint); typedef EGLBoolean(EGLAPIENTRY *PFN_eglDestroySurface)(EGLDisplay, EGLSurface);
typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint); typedef EGLBoolean(EGLAPIENTRY *PFN_eglDestroyContext)(EGLDisplay, EGLContext);
typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*); typedef EGLSurface(EGLAPIENTRY *PFN_eglCreateWindowSurface)(EGLDisplay,
EGLConfig,
EGLNativeWindowType,
const EGLint *);
typedef EGLBoolean(EGLAPIENTRY *PFN_eglMakeCurrent)(EGLDisplay, EGLSurface,
EGLSurface, EGLContext);
typedef EGLBoolean(EGLAPIENTRY *PFN_eglSwapBuffers)(EGLDisplay, EGLSurface);
typedef EGLBoolean(EGLAPIENTRY *PFN_eglSwapInterval)(EGLDisplay, EGLint);
typedef const char *(EGLAPIENTRY *PFN_eglQueryString)(EGLDisplay, EGLint);
typedef GLFWglproc(EGLAPIENTRY *PFN_eglGetProcAddress)(const char *);
#define eglGetConfigAttrib _glfw.egl.GetConfigAttrib #define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
#define eglGetConfigs _glfw.egl.GetConfigs #define eglGetConfigs _glfw.egl.GetConfigs
#define eglGetDisplay _glfw.egl.GetDisplay #define eglGetDisplay _glfw.egl.GetDisplay
@ -233,10 +237,13 @@ typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
#define eglQueryString _glfw.egl.QueryString #define eglQueryString _glfw.egl.QueryString
#define eglGetProcAddress _glfw.egl.GetProcAddress #define eglGetProcAddress _glfw.egl.GetProcAddress
typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*); typedef EGLDisplay(EGLAPIENTRY *PFNEGLGETPLATFORMDISPLAYEXTPROC)(
typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*); EGLenum, void *, const EGLint *);
typedef EGLSurface(EGLAPIENTRY *PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(
EGLDisplay, EGLConfig, void *, const EGLint *);
#define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT #define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT
#define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT #define eglCreatePlatformWindowSurfaceEXT \
_glfw.egl.CreatePlatformWindowSurfaceEXT
#define OSMESA_RGBA 0x1908 #define OSMESA_RGBA 0x1908
#define OSMESA_FORMAT 0x22 #define OSMESA_FORMAT 0x22
@ -249,16 +256,22 @@ typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLD
#define OSMESA_CONTEXT_MAJOR_VERSION 0x36 #define OSMESA_CONTEXT_MAJOR_VERSION 0x36
#define OSMESA_CONTEXT_MINOR_VERSION 0x37 #define OSMESA_CONTEXT_MINOR_VERSION 0x37
typedef void* OSMesaContext; typedef void *OSMesaContext;
typedef void (*OSMESAproc)(void); typedef void (*OSMESAproc)(void);
typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext); typedef OSMesaContext(GLAPIENTRY *PFN_OSMesaCreateContextExt)(GLenum, GLint,
typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext); GLint, GLint,
typedef void (GLAPIENTRY * PFN_OSMesaDestroyContext)(OSMesaContext); OSMesaContext);
typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int); typedef OSMesaContext(GLAPIENTRY *PFN_OSMesaCreateContextAttribs)(
typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**); const int *, OSMesaContext);
typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**); typedef void(GLAPIENTRY *PFN_OSMesaDestroyContext)(OSMesaContext);
typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*); typedef int(GLAPIENTRY *PFN_OSMesaMakeCurrent)(OSMesaContext, void *, int, int,
int);
typedef int(GLAPIENTRY *PFN_OSMesaGetColorBuffer)(OSMesaContext, int *, int *,
int *, void **);
typedef int(GLAPIENTRY *PFN_OSMesaGetDepthBuffer)(OSMesaContext, int *, int *,
int *, void **);
typedef GLFWglproc(GLAPIENTRY *PFN_OSMesaGetProcAddress)(const char *);
#define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt #define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt
#define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs #define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs
#define OSMesaDestroyContext _glfw.osmesa.DestroyContext #define OSMesaDestroyContext _glfw.osmesa.DestroyContext
@ -269,14 +282,13 @@ typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*);
#define VK_NULL_HANDLE 0 #define VK_NULL_HANDLE 0
typedef void* VkInstance; typedef void *VkInstance;
typedef void* VkPhysicalDevice; typedef void *VkPhysicalDevice;
typedef uint64_t VkSurfaceKHR; typedef uint64_t VkSurfaceKHR;
typedef uint32_t VkFlags; typedef uint32_t VkFlags;
typedef uint32_t VkBool32; typedef uint32_t VkBool32;
typedef enum VkStructureType typedef enum VkStructureType {
{
VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR = 1000004000, VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR = 1000004000,
VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR = 1000005000, VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR = 1000005000,
VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000, VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000,
@ -286,8 +298,7 @@ typedef enum VkStructureType
VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
} VkStructureType; } VkStructureType;
typedef enum VkResult typedef enum VkResult {
{
VK_SUCCESS = 0, VK_SUCCESS = 0,
VK_NOT_READY = 1, VK_NOT_READY = 1,
VK_TIMEOUT = 2, VK_TIMEOUT = 2,
@ -316,30 +327,29 @@ typedef enum VkResult
typedef struct VkAllocationCallbacks VkAllocationCallbacks; typedef struct VkAllocationCallbacks VkAllocationCallbacks;
typedef struct VkExtensionProperties typedef struct VkExtensionProperties {
{
char extensionName[256]; char extensionName[256];
uint32_t specVersion; uint32_t specVersion;
} VkExtensionProperties; } VkExtensionProperties;
typedef void (APIENTRY * PFN_vkVoidFunction)(void); typedef void(APIENTRY *PFN_vkVoidFunction)(void);
typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*); typedef PFN_vkVoidFunction(APIENTRY *PFN_vkGetInstanceProcAddr)(VkInstance,
typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*); const char *);
typedef VkResult(APIENTRY *PFN_vkEnumerateInstanceExtensionProperties)(
const char *, uint32_t *, VkExtensionProperties *);
#define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr #define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr
#include "platform.h" #include "platform.h"
// Checks for whether the library has been initialized // Checks for whether the library has been initialized
#define _GLFW_REQUIRE_INIT() \ #define _GLFW_REQUIRE_INIT() \
if (!_glfw.initialized) \ if (!_glfw.initialized) { \
{ \
_glfwInputError(GLFW_NOT_INITIALIZED, NULL); \ _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \
return; \ return; \
} }
#define _GLFW_REQUIRE_INIT_OR_RETURN(x) \ #define _GLFW_REQUIRE_INIT_OR_RETURN(x) \
if (!_glfw.initialized) \ if (!_glfw.initialized) { \
{ \
_glfwInputError(GLFW_NOT_INITIALIZED, NULL); \ _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \
return x; \ return x; \
} }
@ -355,9 +365,8 @@ typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const c
// Per-thread error structure // Per-thread error structure
// //
struct _GLFWerror struct _GLFWerror {
{ _GLFWerror *next;
_GLFWerror* next;
int code; int code;
char description[_GLFW_MESSAGE_SIZE]; char description[_GLFW_MESSAGE_SIZE];
}; };
@ -366,8 +375,7 @@ struct _GLFWerror
// //
// Parameters relating to the initialization of the library // Parameters relating to the initialization of the library
// //
struct _GLFWinitconfig struct _GLFWinitconfig {
{
GLFWbool hatButtons; GLFWbool hatButtons;
int angleType; int angleType;
int platformID; int platformID;
@ -390,16 +398,16 @@ struct _GLFWinitconfig
// to the framebuffer. This is used to pass window creation parameters from // to the framebuffer. This is used to pass window creation parameters from
// shared code to the platform API. // shared code to the platform API.
// //
struct _GLFWwndconfig struct _GLFWwndconfig {
{
int xpos; int xpos;
int ypos; int ypos;
int width; int width;
int height; int height;
const char* title; const char *title;
GLFWbool resizable; GLFWbool resizable;
GLFWbool visible; GLFWbool visible;
GLFWbool decorated; GLFWbool decorated;
GLFWbool titlebar;
GLFWbool focused; GLFWbool focused;
GLFWbool autoIconify; GLFWbool autoIconify;
GLFWbool floating; GLFWbool floating;
@ -430,8 +438,7 @@ struct _GLFWwndconfig
// to the framebuffer. This is used to pass context creation parameters from // to the framebuffer. This is used to pass context creation parameters from
// shared code to the platform API. // shared code to the platform API.
// //
struct _GLFWctxconfig struct _GLFWctxconfig {
{
int client; int client;
int source; int source;
int major; int major;
@ -442,7 +449,7 @@ struct _GLFWctxconfig
int profile; int profile;
int robustness; int robustness;
int release; int release;
_GLFWwindow* share; _GLFWwindow *share;
struct { struct {
GLFWbool offline; GLFWbool offline;
} nsgl; } nsgl;
@ -456,8 +463,7 @@ struct _GLFWctxconfig
// It is used to pass framebuffer parameters from shared code to the platform // It is used to pass framebuffer parameters from shared code to the platform
// API and also to enumerate and select available framebuffer configs. // API and also to enumerate and select available framebuffer configs.
// //
struct _GLFWfbconfig struct _GLFWfbconfig {
{
int redBits; int redBits;
int greenBits; int greenBits;
int blueBits; int blueBits;
@ -479,8 +485,7 @@ struct _GLFWfbconfig
// Context structure // Context structure
// //
struct _GLFWcontext struct _GLFWcontext {
{
int client; int client;
int source; int source;
int major, minor, revision; int major, minor, revision;
@ -493,25 +498,25 @@ struct _GLFWcontext
PFNGLGETINTEGERVPROC GetIntegerv; PFNGLGETINTEGERVPROC GetIntegerv;
PFNGLGETSTRINGPROC GetString; PFNGLGETSTRINGPROC GetString;
void (*makeCurrent)(_GLFWwindow*); void (*makeCurrent)(_GLFWwindow *);
void (*swapBuffers)(_GLFWwindow*); void (*swapBuffers)(_GLFWwindow *);
void (*swapInterval)(int); void (*swapInterval)(int);
int (*extensionSupported)(const char*); int (*extensionSupported)(const char *);
GLFWglproc (*getProcAddress)(const char*); GLFWglproc (*getProcAddress)(const char *);
void (*destroy)(_GLFWwindow*); void (*destroy)(_GLFWwindow *);
struct { struct {
EGLConfig config; EGLConfig config;
EGLContext handle; EGLContext handle;
EGLSurface surface; EGLSurface surface;
void* client; void *client;
} egl; } egl;
struct { struct {
OSMesaContext handle; OSMesaContext handle;
int width; int width;
int height; int height;
void* buffer; void *buffer;
} osmesa; } osmesa;
// This is defined in platform.h // This is defined in platform.h
@ -520,9 +525,8 @@ struct _GLFWcontext
// Window and context structure // Window and context structure
// //
struct _GLFWwindow struct _GLFWwindow {
{ struct _GLFWwindow *next;
struct _GLFWwindow* next;
// Window settings and state // Window settings and state
GLFWbool resizable; GLFWbool resizable;
@ -532,11 +536,11 @@ struct _GLFWwindow
GLFWbool focusOnShow; GLFWbool focusOnShow;
GLFWbool mousePassthrough; GLFWbool mousePassthrough;
GLFWbool shouldClose; GLFWbool shouldClose;
void* userPointer; void *userPointer;
GLFWbool doublebuffer; GLFWbool doublebuffer;
GLFWvidmode videoMode; GLFWvidmode videoMode;
_GLFWmonitor* monitor; _GLFWmonitor *monitor;
_GLFWcursor* cursor; _GLFWcursor *cursor;
int minwidth, minheight; int minwidth, minheight;
int maxwidth, maxheight; int maxwidth, maxheight;
@ -556,6 +560,7 @@ struct _GLFWwindow
struct { struct {
GLFWwindowposfun pos; GLFWwindowposfun pos;
GLFWtitlebarhittestfun tbhittest;
GLFWwindowsizefun size; GLFWwindowsizefun size;
GLFWwindowclosefun close; GLFWwindowclosefun close;
GLFWwindowrefreshfun refresh; GLFWwindowrefreshfun refresh;
@ -580,18 +585,17 @@ struct _GLFWwindow
// Monitor structure // Monitor structure
// //
struct _GLFWmonitor struct _GLFWmonitor {
{
char name[128]; char name[128];
void* userPointer; void *userPointer;
// Physical dimensions in millimeters. // Physical dimensions in millimeters.
int widthMM, heightMM; int widthMM, heightMM;
// The window whose video mode is current on this monitor // The window whose video mode is current on this monitor
_GLFWwindow* window; _GLFWwindow *window;
GLFWvidmode* modes; GLFWvidmode *modes;
int modeCount; int modeCount;
GLFWvidmode currentMode; GLFWvidmode currentMode;
@ -604,17 +608,15 @@ struct _GLFWmonitor
// Cursor structure // Cursor structure
// //
struct _GLFWcursor struct _GLFWcursor {
{ _GLFWcursor *next;
_GLFWcursor* next;
// This is defined in platform.h // This is defined in platform.h
GLFW_PLATFORM_CURSOR_STATE GLFW_PLATFORM_CURSOR_STATE
}; };
// Gamepad mapping element structure // Gamepad mapping element structure
// //
struct _GLFWmapelement struct _GLFWmapelement {
{
uint8_t type; uint8_t type;
uint8_t index; uint8_t index;
int8_t axisScale; int8_t axisScale;
@ -623,8 +625,7 @@ struct _GLFWmapelement
// Gamepad mapping structure // Gamepad mapping structure
// //
struct _GLFWmapping struct _GLFWmapping {
{
char name[128]; char name[128];
char guid[33]; char guid[33];
_GLFWmapelement buttons[15]; _GLFWmapelement buttons[15];
@ -633,20 +634,19 @@ struct _GLFWmapping
// Joystick structure // Joystick structure
// //
struct _GLFWjoystick struct _GLFWjoystick {
{
GLFWbool allocated; GLFWbool allocated;
GLFWbool connected; GLFWbool connected;
float* axes; float *axes;
int axisCount; int axisCount;
unsigned char* buttons; unsigned char *buttons;
int buttonCount; int buttonCount;
unsigned char* hats; unsigned char *hats;
int hatCount; int hatCount;
char name[128]; char name[128];
void* userPointer; void *userPointer;
char guid[33]; char guid[33];
_GLFWmapping* mapping; _GLFWmapping *mapping;
// This is defined in platform.h // This is defined in platform.h
GLFW_PLATFORM_JOYSTICK_STATE GLFW_PLATFORM_JOYSTICK_STATE
@ -654,108 +654,110 @@ struct _GLFWjoystick
// Thread local storage structure // Thread local storage structure
// //
struct _GLFWtls struct _GLFWtls {
{
// This is defined in platform.h // This is defined in platform.h
GLFW_PLATFORM_TLS_STATE GLFW_PLATFORM_TLS_STATE
}; };
// Mutex structure // Mutex structure
// //
struct _GLFWmutex struct _GLFWmutex {
{
// This is defined in platform.h // This is defined in platform.h
GLFW_PLATFORM_MUTEX_STATE GLFW_PLATFORM_MUTEX_STATE
}; };
// Platform API structure // Platform API structure
// //
struct _GLFWplatform struct _GLFWplatform {
{
int platformID; int platformID;
// init // init
GLFWbool (*init)(void); GLFWbool (*init)(void);
void (*terminate)(void); void (*terminate)(void);
// input // input
void (*getCursorPos)(_GLFWwindow*,double*,double*); void (*getCursorPos)(_GLFWwindow *, double *, double *);
void (*setCursorPos)(_GLFWwindow*,double,double); void (*setCursorPos)(_GLFWwindow *, double, double);
void (*setCursorMode)(_GLFWwindow*,int); void (*setCursorMode)(_GLFWwindow *, int);
void (*setRawMouseMotion)(_GLFWwindow*,GLFWbool); void (*setRawMouseMotion)(_GLFWwindow *, GLFWbool);
GLFWbool (*rawMouseMotionSupported)(void); GLFWbool (*rawMouseMotionSupported)(void);
GLFWbool (*createCursor)(_GLFWcursor*,const GLFWimage*,int,int); GLFWbool (*createCursor)(_GLFWcursor *, const GLFWimage *, int, int);
GLFWbool (*createStandardCursor)(_GLFWcursor*,int); GLFWbool (*createStandardCursor)(_GLFWcursor *, int);
void (*destroyCursor)(_GLFWcursor*); void (*destroyCursor)(_GLFWcursor *);
void (*setCursor)(_GLFWwindow*,_GLFWcursor*); void (*setCursor)(_GLFWwindow *, _GLFWcursor *);
const char* (*getScancodeName)(int); const char *(*getScancodeName)(int);
int (*getKeyScancode)(int); int (*getKeyScancode)(int);
void (*setClipboardString)(const char*); void (*setClipboardString)(const char *);
const char* (*getClipboardString)(void); const char *(*getClipboardString)(void);
GLFWbool (*initJoysticks)(void); GLFWbool (*initJoysticks)(void);
void (*terminateJoysticks)(void); void (*terminateJoysticks)(void);
GLFWbool (*pollJoystick)(_GLFWjoystick*,int); GLFWbool (*pollJoystick)(_GLFWjoystick *, int);
const char* (*getMappingName)(void); const char *(*getMappingName)(void);
void (*updateGamepadGUID)(char*); void (*updateGamepadGUID)(char *);
// monitor // monitor
void (*freeMonitor)(_GLFWmonitor*); void (*freeMonitor)(_GLFWmonitor *);
void (*getMonitorPos)(_GLFWmonitor*,int*,int*); void (*getMonitorPos)(_GLFWmonitor *, int *, int *);
void (*getMonitorContentScale)(_GLFWmonitor*,float*,float*); void (*getMonitorContentScale)(_GLFWmonitor *, float *, float *);
void (*getMonitorWorkarea)(_GLFWmonitor*,int*,int*,int*,int*); void (*getMonitorWorkarea)(_GLFWmonitor *, int *, int *, int *, int *);
GLFWvidmode* (*getVideoModes)(_GLFWmonitor*,int*); GLFWvidmode *(*getVideoModes)(_GLFWmonitor *, int *);
void (*getVideoMode)(_GLFWmonitor*,GLFWvidmode*); void (*getVideoMode)(_GLFWmonitor *, GLFWvidmode *);
GLFWbool (*getGammaRamp)(_GLFWmonitor*,GLFWgammaramp*); GLFWbool (*getGammaRamp)(_GLFWmonitor *, GLFWgammaramp *);
void (*setGammaRamp)(_GLFWmonitor*,const GLFWgammaramp*); void (*setGammaRamp)(_GLFWmonitor *, const GLFWgammaramp *);
// window // window
GLFWbool (*createWindow)(_GLFWwindow*,const _GLFWwndconfig*,const _GLFWctxconfig*,const _GLFWfbconfig*); GLFWbool (*createWindow)(_GLFWwindow *, const _GLFWwndconfig *,
void (*destroyWindow)(_GLFWwindow*); const _GLFWctxconfig *, const _GLFWfbconfig *);
void (*setWindowTitle)(_GLFWwindow*,const char*); void (*destroyWindow)(_GLFWwindow *);
void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*); void (*setWindowTitle)(_GLFWwindow *, const char *);
void (*getWindowPos)(_GLFWwindow*,int*,int*); void (*setWindowIcon)(_GLFWwindow *, int, const GLFWimage *);
void (*setWindowPos)(_GLFWwindow*,int,int); void (*getWindowPos)(_GLFWwindow *, int *, int *);
void (*getWindowSize)(_GLFWwindow*,int*,int*); void (*setWindowPos)(_GLFWwindow *, int, int);
void (*setWindowSize)(_GLFWwindow*,int,int); void (*getWindowSize)(_GLFWwindow *, int *, int *);
void (*setWindowSizeLimits)(_GLFWwindow*,int,int,int,int); void (*setWindowSize)(_GLFWwindow *, int, int);
void (*setWindowAspectRatio)(_GLFWwindow*,int,int); void (*setWindowSizeLimits)(_GLFWwindow *, int, int, int, int);
void (*getFramebufferSize)(_GLFWwindow*,int*,int*); void (*setWindowAspectRatio)(_GLFWwindow *, int, int);
void (*getWindowFrameSize)(_GLFWwindow*,int*,int*,int*,int*); void (*getFramebufferSize)(_GLFWwindow *, int *, int *);
void (*getWindowContentScale)(_GLFWwindow*,float*,float*); void (*getWindowFrameSize)(_GLFWwindow *, int *, int *, int *, int *);
void (*iconifyWindow)(_GLFWwindow*); void (*getWindowContentScale)(_GLFWwindow *, float *, float *);
void (*restoreWindow)(_GLFWwindow*); void (*iconifyWindow)(_GLFWwindow *);
void (*maximizeWindow)(_GLFWwindow*); void (*restoreWindow)(_GLFWwindow *);
void (*showWindow)(_GLFWwindow*); void (*maximizeWindow)(_GLFWwindow *);
void (*hideWindow)(_GLFWwindow*); void (*showWindow)(_GLFWwindow *);
void (*requestWindowAttention)(_GLFWwindow*); void (*hideWindow)(_GLFWwindow *);
void (*focusWindow)(_GLFWwindow*); void (*requestWindowAttention)(_GLFWwindow *);
void (*setWindowMonitor)(_GLFWwindow*,_GLFWmonitor*,int,int,int,int,int); void (*focusWindow)(_GLFWwindow *);
GLFWbool (*windowFocused)(_GLFWwindow*); void (*setWindowMonitor)(_GLFWwindow *, _GLFWmonitor *, int, int, int, int,
GLFWbool (*windowIconified)(_GLFWwindow*); int);
GLFWbool (*windowVisible)(_GLFWwindow*); GLFWbool (*windowFocused)(_GLFWwindow *);
GLFWbool (*windowMaximized)(_GLFWwindow*); GLFWbool (*windowIconified)(_GLFWwindow *);
GLFWbool (*windowHovered)(_GLFWwindow*); GLFWbool (*windowVisible)(_GLFWwindow *);
GLFWbool (*framebufferTransparent)(_GLFWwindow*); GLFWbool (*windowMaximized)(_GLFWwindow *);
float (*getWindowOpacity)(_GLFWwindow*); GLFWbool (*windowHovered)(_GLFWwindow *);
void (*setWindowResizable)(_GLFWwindow*,GLFWbool); GLFWbool (*framebufferTransparent)(_GLFWwindow *);
void (*setWindowDecorated)(_GLFWwindow*,GLFWbool); float (*getWindowOpacity)(_GLFWwindow *);
void (*setWindowFloating)(_GLFWwindow*,GLFWbool); void (*setWindowResizable)(_GLFWwindow *, GLFWbool);
void (*setWindowOpacity)(_GLFWwindow*,float); void (*setWindowDecorated)(_GLFWwindow *, GLFWbool);
void (*setWindowMousePassthrough)(_GLFWwindow*,GLFWbool); void (*setWindowTitlebar)(_GLFWwindow *, GLFWbool);
void (*setWindowFloating)(_GLFWwindow *, GLFWbool);
void (*setWindowOpacity)(_GLFWwindow *, float);
void (*setWindowMousePassthrough)(_GLFWwindow *, GLFWbool);
void (*pollEvents)(void); void (*pollEvents)(void);
void (*waitEvents)(void); void (*waitEvents)(void);
void (*waitEventsTimeout)(double); void (*waitEventsTimeout)(double);
void (*postEmptyEvent)(void); void (*postEmptyEvent)(void);
// EGL // EGL
EGLenum (*getEGLPlatform)(EGLint**); EGLenum (*getEGLPlatform)(EGLint **);
EGLNativeDisplayType (*getEGLNativeDisplay)(void); EGLNativeDisplayType (*getEGLNativeDisplay)(void);
EGLNativeWindowType (*getEGLNativeWindow)(_GLFWwindow*); EGLNativeWindowType (*getEGLNativeWindow)(_GLFWwindow *);
// vulkan // vulkan
void (*getRequiredInstanceExtensions)(char**); void (*getRequiredInstanceExtensions)(char **);
GLFWbool (*getPhysicalDevicePresentationSupport)(VkInstance,VkPhysicalDevice,uint32_t); GLFWbool (*getPhysicalDevicePresentationSupport)(VkInstance, VkPhysicalDevice,
VkResult (*createWindowSurface)(VkInstance,_GLFWwindow*,const VkAllocationCallbacks*,VkSurfaceKHR*); uint32_t);
VkResult (*createWindowSurface)(VkInstance, _GLFWwindow *,
const VkAllocationCallbacks *,
VkSurfaceKHR *);
}; };
// Library global data // Library global data
// //
struct _GLFWlibrary struct _GLFWlibrary {
{
GLFWbool initialized; GLFWbool initialized;
GLFWallocator allocator; GLFWallocator allocator;
@ -769,16 +771,16 @@ struct _GLFWlibrary
int refreshRate; int refreshRate;
} hints; } hints;
_GLFWerror* errorListHead; _GLFWerror *errorListHead;
_GLFWcursor* cursorListHead; _GLFWcursor *cursorListHead;
_GLFWwindow* windowListHead; _GLFWwindow *windowListHead;
_GLFWmonitor** monitors; _GLFWmonitor **monitors;
int monitorCount; int monitorCount;
GLFWbool joysticksInitialized; GLFWbool joysticksInitialized;
_GLFWjoystick joysticks[GLFW_JOYSTICK_LAST + 1]; _GLFWjoystick joysticks[GLFW_JOYSTICK_LAST + 1];
_GLFWmapping* mappings; _GLFWmapping *mappings;
int mappingCount; int mappingCount;
_GLFWtls errorSlot; _GLFWtls errorSlot;
@ -813,7 +815,7 @@ struct _GLFWlibrary
GLFWbool ANGLE_platform_angle_vulkan; GLFWbool ANGLE_platform_angle_vulkan;
GLFWbool ANGLE_platform_angle_metal; GLFWbool ANGLE_platform_angle_metal;
void* handle; void *handle;
PFN_eglGetConfigAttrib GetConfigAttrib; PFN_eglGetConfigAttrib GetConfigAttrib;
PFN_eglGetConfigs GetConfigs; PFN_eglGetConfigs GetConfigs;
@ -837,7 +839,7 @@ struct _GLFWlibrary
} egl; } egl;
struct { struct {
void* handle; void *handle;
PFN_OSMesaCreateContextExt CreateContextExt; PFN_OSMesaCreateContextExt CreateContextExt;
PFN_OSMesaCreateContextAttribs CreateContextAttribs; PFN_OSMesaCreateContextAttribs CreateContextAttribs;
@ -851,8 +853,8 @@ struct _GLFWlibrary
struct { struct {
GLFWbool available; GLFWbool available;
void* handle; void *handle;
char* extensions[2]; char *extensions[2];
PFN_vkGetInstanceProcAddr GetInstanceProcAddr; PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
GLFWbool KHR_surface; GLFWbool KHR_surface;
GLFWbool KHR_win32_surface; GLFWbool KHR_win32_surface;
@ -878,7 +880,6 @@ struct _GLFWlibrary
// //
extern _GLFWlibrary _glfw; extern _GLFWlibrary _glfw;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////// GLFW platform API ////// ////// GLFW platform API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -887,126 +888,183 @@ void _glfwPlatformInitTimer(void);
uint64_t _glfwPlatformGetTimerValue(void); uint64_t _glfwPlatformGetTimerValue(void);
uint64_t _glfwPlatformGetTimerFrequency(void); uint64_t _glfwPlatformGetTimerFrequency(void);
GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls); int _glfwPlatformCreateWindow(_GLFWwindow *window,
void _glfwPlatformDestroyTls(_GLFWtls* tls); const _GLFWwndconfig *wndconfig,
void* _glfwPlatformGetTls(_GLFWtls* tls); const _GLFWctxconfig *ctxconfig,
void _glfwPlatformSetTls(_GLFWtls* tls, void* value); const _GLFWfbconfig *fbconfig);
void _glfwPlatformDestroyWindow(_GLFWwindow *window);
void _glfwPlatformSetWindowTitle(_GLFWwindow *window, const char *title);
void _glfwPlatformSetWindowIcon(_GLFWwindow *window, int count,
const GLFWimage *images);
void _glfwPlatformGetWindowPos(_GLFWwindow *window, int *xpos, int *ypos);
void _glfwPlatformSetWindowPos(_GLFWwindow *window, int xpos, int ypos);
void _glfwPlatformGetWindowSize(_GLFWwindow *window, int *width, int *height);
void _glfwPlatformSetWindowSize(_GLFWwindow *window, int width, int height);
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow *window, int minwidth,
int minheight, int maxwidth,
int maxheight);
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow *window, int numer,
int denom);
void _glfwPlatformGetFramebufferSize(_GLFWwindow *window, int *width,
int *height);
void _glfwPlatformGetWindowFrameSize(_GLFWwindow *window, int *left, int *top,
int *right, int *bottom);
void _glfwPlatformGetWindowContentScale(_GLFWwindow *window, float *xscale,
float *yscale);
void _glfwPlatformIconifyWindow(_GLFWwindow *window);
void _glfwPlatformRestoreWindow(_GLFWwindow *window);
void _glfwPlatformMaximizeWindow(_GLFWwindow *window);
void _glfwPlatformShowWindow(_GLFWwindow *window);
void _glfwPlatformHideWindow(_GLFWwindow *window);
void _glfwPlatformRequestWindowAttention(_GLFWwindow *window);
void _glfwPlatformFocusWindow(_GLFWwindow *window);
void _glfwPlatformSetWindowMonitor(_GLFWwindow *window, _GLFWmonitor *monitor,
int xpos, int ypos, int width, int height,
int refreshRate);
int _glfwPlatformWindowFocused(_GLFWwindow *window);
int _glfwPlatformWindowIconified(_GLFWwindow *window);
int _glfwPlatformWindowVisible(_GLFWwindow *window);
int _glfwPlatformWindowMaximized(_GLFWwindow *window);
int _glfwPlatformWindowHovered(_GLFWwindow *window);
int _glfwPlatformFramebufferTransparent(_GLFWwindow *window);
float _glfwPlatformGetWindowOpacity(_GLFWwindow *window);
void _glfwPlatformSetWindowResizable(_GLFWwindow *window, GLFWbool enabled);
void _glfwPlatformSetWindowDecorated(_GLFWwindow *window, GLFWbool enabled);
void _glfwPlatformSetWindowTitlebar(_GLFWwindow *window, GLFWbool enabled);
void _glfwPlatformSetWindowFloating(_GLFWwindow *window, GLFWbool enabled);
void _glfwPlatformSetWindowOpacity(_GLFWwindow *window, float opacity);
GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex); void _glfwPlatformPollEvents(void);
void _glfwPlatformDestroyMutex(_GLFWmutex* mutex); void _glfwPlatformWaitEvents(void);
void _glfwPlatformLockMutex(_GLFWmutex* mutex); void _glfwPlatformWaitEventsTimeout(double timeout);
void _glfwPlatformUnlockMutex(_GLFWmutex* mutex); void _glfwPlatformPostEmptyEvent(void);
void* _glfwPlatformLoadModule(const char* path); void _glfwPlatformGetRequiredInstanceExtensions(char **extensions);
void _glfwPlatformFreeModule(void* module); int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name); VkPhysicalDevice device,
uint32_t queuefamily);
VkResult
_glfwPlatformCreateWindowSurface(VkInstance instance, _GLFWwindow *window,
const VkAllocationCallbacks *allocator,
VkSurfaceKHR *surface);
GLFWbool _glfwPlatformCreateTls(_GLFWtls *tls);
void _glfwPlatformDestroyTls(_GLFWtls *tls);
void *_glfwPlatformGetTls(_GLFWtls *tls);
void _glfwPlatformSetTls(_GLFWtls *tls, void *value);
GLFWbool _glfwPlatformCreateMutex(_GLFWmutex *mutex);
void _glfwPlatformDestroyMutex(_GLFWmutex *mutex);
void _glfwPlatformLockMutex(_GLFWmutex *mutex);
void _glfwPlatformUnlockMutex(_GLFWmutex *mutex);
void *_glfwPlatformLoadModule(const char *path);
void _glfwPlatformFreeModule(void *module);
GLFWproc _glfwPlatformGetModuleSymbol(void *module, const char *name);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////// GLFW event API ////// ////// GLFW event API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused); void _glfwInputWindowFocus(_GLFWwindow *window, GLFWbool focused);
void _glfwInputWindowPos(_GLFWwindow* window, int xpos, int ypos); void _glfwInputWindowPos(_GLFWwindow *window, int xpos, int ypos);
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height); void _glfwInputWindowSize(_GLFWwindow *window, int width, int height);
void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height); void _glfwInputTitleBarHitTest(_GLFWwindow *window, int posX, int posY,
void _glfwInputWindowContentScale(_GLFWwindow* window, int *hit);
float xscale, float yscale); void _glfwInputFramebufferSize(_GLFWwindow *window, int width, int height);
void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified); void _glfwInputWindowContentScale(_GLFWwindow *window, float xscale,
void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized); float yscale);
void _glfwInputWindowDamage(_GLFWwindow* window); void _glfwInputWindowIconify(_GLFWwindow *window, GLFWbool iconified);
void _glfwInputWindowCloseRequest(_GLFWwindow* window); void _glfwInputWindowMaximize(_GLFWwindow *window, GLFWbool maximized);
void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor); void _glfwInputWindowDamage(_GLFWwindow *window);
void _glfwInputWindowCloseRequest(_GLFWwindow *window);
void _glfwInputWindowMonitor(_GLFWwindow *window, _GLFWmonitor *monitor);
void _glfwInputKey(_GLFWwindow* window, void _glfwInputKey(_GLFWwindow *window, int key, int scancode, int action,
int key, int scancode, int action, int mods); int mods);
void _glfwInputChar(_GLFWwindow* window, void _glfwInputChar(_GLFWwindow *window, uint32_t codepoint, int mods,
uint32_t codepoint, int mods, GLFWbool plain); GLFWbool plain);
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset); void _glfwInputScroll(_GLFWwindow *window, double xoffset, double yoffset);
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods); void _glfwInputMouseClick(_GLFWwindow *window, int button, int action,
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos); int mods);
void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered); void _glfwInputCursorPos(_GLFWwindow *window, double xpos, double ypos);
void _glfwInputDrop(_GLFWwindow* window, int count, const char** names); void _glfwInputCursorEnter(_GLFWwindow *window, GLFWbool entered);
void _glfwInputJoystick(_GLFWjoystick* js, int event); void _glfwInputDrop(_GLFWwindow *window, int count, const char **names);
void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value); void _glfwInputJoystick(_GLFWjoystick *js, int event);
void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value); void _glfwInputJoystickAxis(_GLFWjoystick *js, int axis, float value);
void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value); void _glfwInputJoystickButton(_GLFWjoystick *js, int button, char value);
void _glfwInputJoystickHat(_GLFWjoystick *js, int hat, char value);
void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement); void _glfwInputMonitor(_GLFWmonitor *monitor, int action, int placement);
void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window); void _glfwInputMonitorWindow(_GLFWmonitor *monitor, _GLFWwindow *window);
#if defined(__GNUC__) #if defined(__GNUC__)
void _glfwInputError(int code, const char* format, ...) void _glfwInputError(int code, const char *format, ...)
__attribute__((format(printf, 2, 3))); __attribute__((format(printf, 2, 3)));
#else #else
void _glfwInputError(int code, const char* format, ...); void _glfwInputError(int code, const char *format, ...);
#endif #endif
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////// GLFW internal API ////// ////// GLFW internal API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
GLFWbool _glfwSelectPlatform(int platformID, _GLFWplatform* platform); GLFWbool _glfwSelectPlatform(int platformID, _GLFWplatform *platform);
GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions); GLFWbool _glfwStringInExtensionString(const char *string,
const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired, const char *extensions);
const _GLFWfbconfig* alternatives, const _GLFWfbconfig *_glfwChooseFBConfig(const _GLFWfbconfig *desired,
const _GLFWfbconfig *alternatives,
unsigned int count); unsigned int count);
GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window, GLFWbool _glfwRefreshContextAttribs(_GLFWwindow *window,
const _GLFWctxconfig* ctxconfig); const _GLFWctxconfig *ctxconfig);
GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig); GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig *ctxconfig);
const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor, const GLFWvidmode *_glfwChooseVideoMode(_GLFWmonitor *monitor,
const GLFWvidmode* desired); const GLFWvidmode *desired);
int _glfwCompareVideoModes(const GLFWvidmode* first, const GLFWvidmode* second); int _glfwCompareVideoModes(const GLFWvidmode *first, const GLFWvidmode *second);
_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM); _GLFWmonitor *_glfwAllocMonitor(const char *name, int widthMM, int heightMM);
void _glfwFreeMonitor(_GLFWmonitor* monitor); void _glfwFreeMonitor(_GLFWmonitor *monitor);
void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size); void _glfwAllocGammaArrays(GLFWgammaramp *ramp, unsigned int size);
void _glfwFreeGammaArrays(GLFWgammaramp* ramp); void _glfwFreeGammaArrays(GLFWgammaramp *ramp);
void _glfwSplitBPP(int bpp, int* red, int* green, int* blue); void _glfwSplitBPP(int bpp, int *red, int *green, int *blue);
void _glfwInitGamepadMappings(void); void _glfwInitGamepadMappings(void);
_GLFWjoystick* _glfwAllocJoystick(const char* name, _GLFWjoystick *_glfwAllocJoystick(const char *name, const char *guid,
const char* guid, int axisCount, int buttonCount, int hatCount);
int axisCount, void _glfwFreeJoystick(_GLFWjoystick *js);
int buttonCount, void _glfwCenterCursorInContentArea(_GLFWwindow *window);
int hatCount);
void _glfwFreeJoystick(_GLFWjoystick* js);
void _glfwCenterCursorInContentArea(_GLFWwindow* window);
GLFWbool _glfwInitEGL(void); GLFWbool _glfwInitEGL(void);
void _glfwTerminateEGL(void); void _glfwTerminateEGL(void);
GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, GLFWbool _glfwCreateContextEGL(_GLFWwindow *window,
const _GLFWctxconfig* ctxconfig, const _GLFWctxconfig *ctxconfig,
const _GLFWfbconfig* fbconfig); const _GLFWfbconfig *fbconfig);
#if defined(_GLFW_X11) #if defined(_GLFW_X11)
GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig, GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig *wndconfig,
const _GLFWctxconfig* ctxconfig, const _GLFWctxconfig *ctxconfig,
const _GLFWfbconfig* fbconfig, const _GLFWfbconfig *fbconfig, Visual **visual,
Visual** visual, int* depth); int *depth);
#endif /*_GLFW_X11*/ #endif /*_GLFW_X11*/
GLFWbool _glfwInitOSMesa(void); GLFWbool _glfwInitOSMesa(void);
void _glfwTerminateOSMesa(void); void _glfwTerminateOSMesa(void);
GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window, GLFWbool _glfwCreateContextOSMesa(_GLFWwindow *window,
const _GLFWctxconfig* ctxconfig, const _GLFWctxconfig *ctxconfig,
const _GLFWfbconfig* fbconfig); const _GLFWfbconfig *fbconfig);
GLFWbool _glfwInitVulkan(int mode); GLFWbool _glfwInitVulkan(int mode);
void _glfwTerminateVulkan(void); void _glfwTerminateVulkan(void);
const char* _glfwGetVulkanResultString(VkResult result); const char *_glfwGetVulkanResultString(VkResult result);
size_t _glfwEncodeUTF8(char* s, uint32_t codepoint); size_t _glfwEncodeUTF8(char *s, uint32_t codepoint);
char** _glfwParseUriList(char* text, int* count); char **_glfwParseUriList(char *text, int *count);
char* _glfw_strdup(const char* source); char *_glfw_strdup(const char *source);
int _glfw_min(int a, int b); int _glfw_min(int a, int b);
int _glfw_max(int a, int b); int _glfw_max(int a, int b);
float _glfw_fminf(float a, float b); float _glfw_fminf(float a, float b);
float _glfw_fmaxf(float a, float b); float _glfw_fmaxf(float a, float b);
void* _glfw_calloc(size_t count, size_t size); void *_glfw_calloc(size_t count, size_t size);
void* _glfw_realloc(void* pointer, size_t size); void *_glfw_realloc(void *pointer, size_t size);
void _glfw_free(void* pointer); void _glfw_free(void *pointer);

View File

@ -2130,6 +2130,10 @@ int main(const int argc, const char *argv[]) {
demo_create_window(&demo); demo_create_window(&demo);
demo_init_vk_swapchain(&demo); demo_init_vk_swapchain(&demo);
glfwSetWindowAttrib(demo.window, GLFW_RESIZABLE, GLFW_TRUE);
glfwSetWindowAttrib(demo.window, GLFW_TITLEBAR, GLFW_FALSE);
demo_prepare(&demo); demo_prepare(&demo);
demo_run(&demo); demo_run(&demo);