From 97ae40496d473e90dfa02041e3f67287a67b095c Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 7 Nov 2013 15:17:25 +0100 Subject: [PATCH 01/52] Added reporting of extension string retrieval failure. --- src/context.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/context.c b/src/context.c index ca7b8d61c..cdc9d911c 100644 --- a/src/context.c +++ b/src/context.c @@ -566,7 +566,7 @@ GLFWAPI int glfwExtensionSupported(const char* extension) return GL_FALSE; } - if (extension == NULL || *extension == '\0') + if (!extension || *extension == '\0') { _glfwInputError(GLFW_INVALID_VALUE, NULL); return GL_FALSE; @@ -577,11 +577,15 @@ GLFWAPI int glfwExtensionSupported(const char* extension) // Check if extension is in the old style OpenGL extensions string extensions = glGetString(GL_EXTENSIONS); - if (extensions != NULL) + if (!extensions) { - if (_glfwStringInExtensionString(extension, extensions)) - return GL_TRUE; + _glfwInputError(GLFW_PLATFORM_ERROR, + "Failed to retrieve extension string"); + return GL_FALSE; } + + if (_glfwStringInExtensionString(extension, extensions)) + return GL_TRUE; } #if defined(_GLFW_USE_OPENGL) else @@ -596,11 +600,15 @@ GLFWAPI int glfwExtensionSupported(const char* extension) for (i = 0; i < count; i++) { const char* en = (const char*) window->GetStringi(GL_EXTENSIONS, i); - if (en != NULL) + if (!en) { - if (strcmp(en, extension) == 0) - return GL_TRUE; + _glfwInputError(GLFW_PLATFORM_ERROR, + "Failed to retrieve extension string %i", i); + return GL_FALSE; } + + if (strcmp(en, extension) == 0) + return GL_TRUE; } } #endif // _GLFW_USE_OPENGL From cc7f0bd532067b6259dfe8195a4150a178986818 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 7 Nov 2013 16:20:52 +0100 Subject: [PATCH 02/52] Fixed crash retrieving the name of some displays. --- README.md | 1 + src/cocoa_monitor.m | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 848bc303b..729f74da0 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ guide in the GLFW documentation. - [Cocoa] Bugfix: Full screen windows were never reported as having focus - [Cocoa] Bugfix: A superfluous I/O flag test prevented video modes from being listed for Thunderbolt monitor + - [Cocoa] Bugfix: Retrieving the name of some external displays caused segfault - [X11] Added setting of the `WM_CLASS` property to the initial window title - [X11] Bugfix: Removed joystick axis value negation left over from GLFW 2 - [X11] Bugfix: The position of hidden windows was ignored by Metacity diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 504a5fc9a..caddde403 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -49,9 +49,11 @@ static const char* getDisplayName(CGDirectDisplayID displayID) kIODisplayOnlyPreferredName); names = CFDictionaryGetValue(info, CFSTR(kDisplayProductName)); - if (!CFDictionaryGetValueIfPresent(names, CFSTR("en_US"), - (const void**) &value)) + if (!names || !CFDictionaryGetValueIfPresent(names, CFSTR("en_US"), + (const void**) &value)) { + _glfwInputError(GLFW_PLATFORM_ERROR, "Failed to retrieve display name"); + CFRelease(info); return strdup("Unknown"); } From e7c7ebf6658963edbca3945c1732e0116798d8dd Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 7 Nov 2013 17:20:06 +0100 Subject: [PATCH 03/52] Added workaround for 10.9 SDK type definitions. --- README.md | 2 ++ deps/GL/glext.h | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 729f74da0..26ed1525e 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,8 @@ guide in the GLFW documentation. - [Cocoa] Bugfix: A superfluous I/O flag test prevented video modes from being listed for Thunderbolt monitor - [Cocoa] Bugfix: Retrieving the name of some external displays caused segfault + - [Cocoa] Bugfix: The 10.9 SDK defines `GLintptrARB` and `GLsizeiptrARB` + differently from the Khronos `glext.h` - [X11] Added setting of the `WM_CLASS` property to the initial window title - [X11] Bugfix: Removed joystick axis value negation left over from GLFW 2 - [X11] Bugfix: The position of hidden windows was ignored by Metacity diff --git a/deps/GL/glext.h b/deps/GL/glext.h index 6cd79a207..acb469833 100644 --- a/deps/GL/glext.h +++ b/deps/GL/glext.h @@ -4130,8 +4130,13 @@ GLAPI void APIENTRY glVertexBlendARB (GLint count); #ifndef GL_ARB_vertex_buffer_object #define GL_ARB_vertex_buffer_object 1 +#if defined(__APPLE__) +typedef long GLsizeiptrARB; +typedef long GLintptrARB; +#else typedef ptrdiff_t GLsizeiptrARB; typedef ptrdiff_t GLintptrARB; +#endif #define GL_BUFFER_SIZE_ARB 0x8764 #define GL_BUFFER_USAGE_ARB 0x8765 #define GL_ARRAY_BUFFER_ARB 0x8892 From ec5cb9c6f70e274184027def5da1ad865c0b7c2e Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 7 Nov 2013 18:03:39 +0100 Subject: [PATCH 04/52] Moved to Cocoa for transformation and activation. --- README.md | 1 + src/cocoa_window.m | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 26ed1525e..dba6a0a74 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ guide in the GLFW documentation. unfocused windows - [Cocoa] Added dependency on CoreVideo framework for refresh rate retrieval - [Cocoa] Enabled Lion full screen for resizable windowed mode windows + - [Cocoa] Moved to Cocoa API for application transformation and activation - [Cocoa] Bugfix: The `GLFW_KEY_GRAVE_ACCENT` key was reported as `GLFW_KEY_WORLD_1` and vice versa - [Cocoa] Bugfix: The `GLFW_KEY_F13` key was reported as diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 5010a19ad..7bc85b93b 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -827,13 +827,11 @@ static GLboolean initializeAppKit(void) // Implicitly create shared NSApplication instance [GLFWApplication sharedApplication]; - // If we get here, the application is unbundled - ProcessSerialNumber psn = { 0, kCurrentProcess }; - TransformProcessType(&psn, kProcessTransformToForegroundApplication); + // In case we are unbundled, make us a proper UI application + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; - // Having the app in front of the terminal window is also generally - // handy. There is an NSApplication API to do this, but... - SetFrontProcess(&psn); + // Make us the active application + [NSApp activateIgnoringOtherApps:YES]; #if defined(_GLFW_USE_MENUBAR) // Menu bar setup must go between sharedApplication above and From a83d257ac604e26e92a71d328cc1a7273341eab7 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 7 Nov 2013 18:07:46 +0100 Subject: [PATCH 05/52] Moved application activation to window showing. Fixes #93. --- README.md | 1 + src/cocoa_window.m | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dba6a0a74..5ef35f174 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ guide in the GLFW documentation. - [Cocoa] Bugfix: Retrieving the name of some external displays caused segfault - [Cocoa] Bugfix: The 10.9 SDK defines `GLintptrARB` and `GLsizeiptrARB` differently from the Khronos `glext.h` + - [Cocoa] Bugfix: Creating hidden windows would steal application focus - [X11] Added setting of the `WM_CLASS` property to the initial window title - [X11] Bugfix: Removed joystick axis value negation left over from GLFW 2 - [X11] Bugfix: The position of hidden windows was ignored by Metacity diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 7bc85b93b..48e4d703a 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -830,9 +830,6 @@ static GLboolean initializeAppKit(void) // In case we are unbundled, make us a proper UI application [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; - // Make us the active application - [NSApp activateIgnoringOtherApps:YES]; - #if defined(_GLFW_USE_MENUBAR) // Menu bar setup must go between sharedApplication above and // finishLaunching below, in order to properly emulate the behavior @@ -1038,6 +1035,9 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window) void _glfwPlatformShowWindow(_GLFWwindow* window) { + // Make us the active application + [NSApp activateIgnoringOtherApps:YES]; + [window->ns.object makeKeyAndOrderFront:nil]; _glfwInputWindowVisibility(window, GL_TRUE); } From 6c12ffc902342fd70849371c241ea7b3819765bc Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 7 Nov 2013 18:22:44 +0100 Subject: [PATCH 06/52] Added the GLFW_BUILD_DOCS CMake option. --- CMakeLists.txt | 13 ++++++++----- README.md | 2 ++ docs/compile.dox | 3 +++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a698baa9d..0a809003e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ set(LIB_SUFFIX "" CACHE STRING "Takes an empty string or 64. Directory where lib option(BUILD_SHARED_LIBS "Build shared libraries" OFF) option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ON) option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON) +option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON) option(GLFW_INSTALL "Generate installation target" ON) option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF) @@ -73,11 +74,13 @@ endif() find_package(Threads REQUIRED) -set(DOXYGEN_SKIP_DOT TRUE) -find_package(Doxygen) +if (GLFW_BUILD_DOCS) + set(DOXYGEN_SKIP_DOT TRUE) + find_package(Doxygen) -if (GLFW_DOCUMENT_INTERNALS) - set(GLFW_INTERNAL_DOCS "${GLFW_SOURCE_DIR}/src/internal.h ${GLFW_SOURCE_DIR}/docs/internal.dox") + if (GLFW_DOCUMENT_INTERNALS) + set(GLFW_INTERNAL_DOCS "${GLFW_SOURCE_DIR}/src/internal.h ${GLFW_SOURCE_DIR}/docs/internal.dox") + endif() endif() #-------------------------------------------------------------------- @@ -407,7 +410,7 @@ if (GLFW_BUILD_TESTS) add_subdirectory(tests) endif() -if (DOXYGEN_FOUND) +if (DOXYGEN_FOUND AND GLFW_BUILD_DOCS) add_subdirectory(docs) endif() diff --git a/README.md b/README.md index 5ef35f174..7ebb8885b 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,8 @@ guide in the GLFW documentation. ## Changelog + - Added the `GLFW_BUILD_DOCS` CMake option for controlling whether the + documentation is built - Renamed configuration header to `glfw_config.h` to avoid conflicts - Bugfix: The `glfw3.pc` file did not respect the `LIB_SUFFIX` CMake option - [Win32] Bugfix: Removed joystick axis value negation left over from GLFW 2 diff --git a/docs/compile.dox b/docs/compile.dox index 579f10a2c..e57b6b267 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -149,6 +149,9 @@ along with the library. `GLFW_BUILD_TESTS` determines whether the GLFW test programs are built along with the library. +`GLFW_BUILD_DOCS` determines whether the GLFW documentation is built along with +the library. + @subsection compile_options_osx OS X specific CMake options From cc4c7167fdee31c91fcfeefa558c0a08f2564d67 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 7 Nov 2013 19:29:33 +0100 Subject: [PATCH 07/52] Fixed joysticks test segfault. --- README.md | 1 + tests/joysticks.c | 62 +++++++++++++++++++++++++---------------------- 2 files changed, 34 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 7ebb8885b..d6b4bcd01 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ guide in the GLFW documentation. documentation is built - Renamed configuration header to `glfw_config.h` to avoid conflicts - Bugfix: The `glfw3.pc` file did not respect the `LIB_SUFFIX` CMake option + - Bugfix: The `joysticks` test would segfault if a controller had no axes - [Win32] Bugfix: Removed joystick axis value negation left over from GLFW 2 - [Win32] Bugfix: Restoring windows using the Win+D hot key did not trigger the focus callback diff --git a/tests/joysticks.c b/tests/joysticks.c index cd49cd468..a3a5cd7e7 100644 --- a/tests/joysticks.c +++ b/tests/joysticks.c @@ -64,43 +64,47 @@ static void framebuffer_size_callback(GLFWwindow* window, int width, int height) static void draw_joystick(Joystick* j, int x, int y, int width, int height) { int i; - int axis_width, axis_height; - int button_width, button_height; + const int axis_height = 3 * height / 4; + const int button_height = height / 4; - axis_width = width / j->axis_count; - axis_height = 3 * height / 4; - - button_width = width / j->button_count; - button_height = height / 4; - - for (i = 0; i < j->axis_count; i++) + if (j->axis_count) { - float value = j->axes[i] / 2.f + 0.5f; + const int axis_width = width / j->axis_count; - glColor3f(0.3f, 0.3f, 0.3f); - glRecti(x + i * axis_width, - y, - x + (i + 1) * axis_width, - y + axis_height); + for (i = 0; i < j->axis_count; i++) + { + float value = j->axes[i] / 2.f + 0.5f; - glColor3f(1.f, 1.f, 1.f); - glRecti(x + i * axis_width, - y + (int) (value * (axis_height - 5)), - x + (i + 1) * axis_width, - y + 5 + (int) (value * (axis_height - 5))); + glColor3f(0.3f, 0.3f, 0.3f); + glRecti(x + i * axis_width, + y, + x + (i + 1) * axis_width, + y + axis_height); + + glColor3f(1.f, 1.f, 1.f); + glRecti(x + i * axis_width, + y + (int) (value * (axis_height - 5)), + x + (i + 1) * axis_width, + y + 5 + (int) (value * (axis_height - 5))); + } } - for (i = 0; i < j->button_count; i++) + if (j->button_count) { - if (j->buttons[i]) - glColor3f(1.f, 1.f, 1.f); - else - glColor3f(0.3f, 0.3f, 0.3f); + const int button_width = width / j->button_count; - glRecti(x + i * button_width, - y + axis_height, - x + (i + 1) * button_width, - y + axis_height + button_height); + for (i = 0; i < j->button_count; i++) + { + if (j->buttons[i]) + glColor3f(1.f, 1.f, 1.f); + else + glColor3f(0.3f, 0.3f, 0.3f); + + glRecti(x + i * button_width, + y + axis_height, + x + (i + 1) * button_width, + y + axis_height + button_height); + } } } From 4013f733fe9841bc3d81c3d5679b5517be12e644 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 7 Nov 2013 20:11:50 +0100 Subject: [PATCH 08/52] Reverted change of IOKit functions. The previously used set of functions caused a regression where no axes or buttons were reported. Fixes #78. --- src/cocoa_joystick.m | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m index 6824726fd..e333ab7ed 100644 --- a/src/cocoa_joystick.m +++ b/src/cocoa_joystick.m @@ -319,8 +319,9 @@ void _glfwInitJoysticks(void) while ((ioHIDDeviceObject = IOIteratorNext(objectIterator))) { + CFMutableDictionaryRef propsRef = NULL; + CFTypeRef valueRef = NULL; kern_return_t result; - CFTypeRef valueRef = 0; IOCFPlugInInterface** ppPlugInInterface = NULL; HRESULT plugInResult = S_OK; @@ -329,26 +330,29 @@ void _glfwInitJoysticks(void) long usagePage, usage; // Check device type - valueRef = IORegistryEntryCreateCFProperty(ioHIDDeviceObject, - CFSTR(kIOHIDPrimaryUsagePageKey), + result = IORegistryEntryCreateCFProperties(ioHIDDeviceObject, + &propsRef, kCFAllocatorDefault, kNilOptions); + + if (result != kIOReturnSuccess) + continue; + + valueRef = CFDictionaryGetValue(propsRef, CFSTR(kIOHIDPrimaryUsagePageKey)); if (valueRef) { CFNumberGetValue(valueRef, kCFNumberLongType, &usagePage); if (usagePage != kHIDPage_GenericDesktop) { // This device is not relevant to GLFW + CFRelease(valueRef); continue; } CFRelease(valueRef); } - valueRef = IORegistryEntryCreateCFProperty(ioHIDDeviceObject, - CFSTR(kIOHIDPrimaryUsageKey), - kCFAllocatorDefault, - kNilOptions); + valueRef = CFDictionaryGetValue(propsRef, CFSTR(kIOHIDPrimaryUsageKey)); if (valueRef) { CFNumberGetValue(valueRef, kCFNumberLongType, &usage); @@ -358,6 +362,7 @@ void _glfwInitJoysticks(void) usage != kHIDUsage_GD_MultiAxisController)) { // This device is not relevant to GLFW + CFRelease(valueRef); continue; } @@ -393,10 +398,7 @@ void _glfwInitJoysticks(void) joystick); // Get product string - valueRef = IORegistryEntryCreateCFProperty(ioHIDDeviceObject, - CFSTR(kIOHIDProductKey), - kCFAllocatorDefault, - kNilOptions); + valueRef = CFDictionaryGetValue(propsRef, CFSTR(kIOHIDProductKey)); if (valueRef) { CFStringGetCString(valueRef, @@ -410,10 +412,7 @@ void _glfwInitJoysticks(void) joystick->buttonElements = CFArrayCreateMutable(NULL, 0, NULL); joystick->hatElements = CFArrayCreateMutable(NULL, 0, NULL); - valueRef = IORegistryEntryCreateCFProperty(ioHIDDeviceObject, - CFSTR(kIOHIDElementKey), - kCFAllocatorDefault, - kNilOptions); + valueRef = CFDictionaryGetValue(propsRef, CFSTR(kIOHIDElementKey)); if (CFGetTypeID(valueRef) == CFArrayGetTypeID()) { CFRange range = { 0, CFArrayGetCount(valueRef) }; From b410cff68cb843ea5f0b8dca4a5bea1c7bf47e51 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 7 Nov 2013 20:36:45 +0100 Subject: [PATCH 09/52] Updated change log. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d6b4bcd01..2634213c8 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ guide in the GLFW documentation. - [Cocoa] Bugfix: The 10.9 SDK defines `GLintptrARB` and `GLsizeiptrARB` differently from the Khronos `glext.h` - [Cocoa] Bugfix: Creating hidden windows would steal application focus + - [Cocoa] Bugfix: Controllers were reported as having zero buttons and axes - [X11] Added setting of the `WM_CLASS` property to the initial window title - [X11] Bugfix: Removed joystick axis value negation left over from GLFW 2 - [X11] Bugfix: The position of hidden windows was ignored by Metacity From b13c84f8541ab9dcb4f6d8ca0605cbb0012869d4 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 7 Nov 2013 20:45:29 +0100 Subject: [PATCH 10/52] Removed joystick axis value negation on OS X. --- README.md | 1 + src/cocoa_joystick.m | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 2634213c8..3400a59e6 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ guide in the GLFW documentation. differently from the Khronos `glext.h` - [Cocoa] Bugfix: Creating hidden windows would steal application focus - [Cocoa] Bugfix: Controllers were reported as having zero buttons and axes + - [Cocoa] Bugfix: Removed joystick axis value negation left over from GLFW 2 - [X11] Added setting of the `WM_CLASS` property to the initial window title - [X11] Bugfix: Removed joystick axis value negation left over from GLFW 2 - [X11] Bugfix: The position of hidden windows was ignored by Metacity diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m index e333ab7ed..7af1042b5 100644 --- a/src/cocoa_joystick.m +++ b/src/cocoa_joystick.m @@ -251,9 +251,6 @@ static void pollJoystickEvents(void) joystick->axes[i] = value; else joystick->axes[i] = (2.f * (value - axis->minReport) / readScale) - 1.f; - - if (i & 1) - joystick->axes[i] = -joystick->axes[i]; } for (i = 0; i < CFArrayGetCount(joystick->hatElements); i++) From a79c844c4d216b28ca3e7d4224cc175a7f381954 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 10 Nov 2013 03:31:10 +0100 Subject: [PATCH 11/52] Oh dear. --- docs/compile.dox | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/compile.dox b/docs/compile.dox index e57b6b267..6a51f62bd 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -81,9 +81,10 @@ not* tie your binaries to the Mesa implementation of OpenGL. Once you have all necessary dependencies it is time to generate the project files or makefiles for your development environment. CMake needs to know two -paths for this: the path to the source directory and the target path for the -generated files and compiled binaries. If these are the same, it is called an -in-tree build, otherwise it is called an out-of-tree build. +paths for this: the path to the *root* directory of the GLFW source tree (i.e. +*not* the `src` subdirectory) and the target path for the generated files and +compiled binaries. If these are the same, it is called an in-tree build, +otherwise it is called an out-of-tree build. One of several advantages of out-of-tree builds is that you can generate files and compile for different development environments using a single source tree. @@ -91,9 +92,10 @@ and compile for different development environments using a single source tree. @subsection compile_cmake_cli Generating files with the CMake command-line tool -To make an in-tree build, enter the root directory of the GLFW source tree and -run CMake. The current directory is used as target path, while the path -provided as an argument is used to find the source tree. +To make an in-tree build, enter the *root* directory of the GLFW source tree +(i.e. *not* the `src` subdirectory) and run CMake. The current directory is +used as target path, while the path provided as an argument is used to find the +source tree. cd cmake . From b9d4875f3e05876035eb773ea6e69ccc9b359e1d Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 10 Nov 2013 13:56:27 +0100 Subject: [PATCH 12/52] Improved documentation of hacks. --- deps/GL/glext.h | 3 +++ src/cocoa_window.m | 7 +++++-- src/context.c | 4 ++-- src/glx_context.c | 7 ++++--- src/x11_window.c | 9 ++++++--- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/deps/GL/glext.h b/deps/GL/glext.h index acb469833..4edeae9f4 100644 --- a/deps/GL/glext.h +++ b/deps/GL/glext.h @@ -4130,6 +4130,9 @@ GLAPI void APIENTRY glVertexBlendARB (GLint count); #ifndef GL_ARB_vertex_buffer_object #define GL_ARB_vertex_buffer_object 1 +/* HACK: This is a workaround for gltypes.h on OS X 10.9 defining these types as + * long instead of ptrdiff_t + */ #if defined(__APPLE__) typedef long GLsizeiptrARB; typedef long GLintptrARB; diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 48e4d703a..24a41fa02 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -67,7 +67,7 @@ static void enterFullscreenMode(_GLFWwindow* window) withOptions:options]; // HACK: Synthesize focus event as window does not become key when the view - // is made full screen + // is made full screen // TODO: Remove this when moving to a full screen window _glfwInputWindowFocus(window, GL_TRUE); } @@ -80,7 +80,7 @@ static void leaveFullscreenMode(_GLFWwindow* window) return; // HACK: Synthesize focus event as window does not become key when the view - // is made full screen + // is made full screen // TODO: Remove this when moving to a full screen window _glfwInputWindowFocus(window, GL_FALSE); @@ -1036,6 +1036,9 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window) void _glfwPlatformShowWindow(_GLFWwindow* window) { // Make us the active application + // HACK: This has been moved here from initializeAppKit to prevent + // applications using only hidden windows from being activated, but + // should probably not be done every time any window is shown [NSApp activateIgnoringOtherApps:YES]; [window->ns.object makeKeyAndOrderFront:nil]; diff --git a/src/context.c b/src/context.c index cdc9d911c..9279af8e2 100644 --- a/src/context.c +++ b/src/context.c @@ -402,8 +402,8 @@ GLboolean _glfwRefreshContextAttribs(void) else if (glfwExtensionSupported("GL_ARB_debug_output")) { // HACK: This is a workaround for older drivers (pre KHR_debug) - // not setting the debug bit in the context flags for debug - // contexts + // not setting the debug bit in the context flags for + // debug contexts window->glDebug = GL_TRUE; } } diff --git a/src/glx_context.c b/src/glx_context.c index 58c257572..824ffab34 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -75,7 +75,7 @@ static GLboolean chooseFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* resul if (strcmp(vendor, "Chromium") == 0) { // HACK: This is a (hopefully temporary) workaround for Chromium - // (VirtualBox GL) not setting the window bit on any GLXFBConfigs + // (VirtualBox GL) not setting the window bit on any GLXFBConfigs trustWindowBit = GL_FALSE; } @@ -485,8 +485,9 @@ int _glfwCreateContext(_GLFWwindow* window, if (window->glx.context == NULL) { // HACK: This is a fallback for the broken Mesa implementation of - // GLX_ARB_create_context_profile, which fails default 1.0 context - // creation with a GLXBadProfileARB error in violation of the spec + // GLX_ARB_create_context_profile, which fails default 1.0 + // context creation with a GLXBadProfileARB error in violation + // of the extension spec if (_glfw.x11.errorCode == _glfw.glx.errorBase + GLXBadProfileARB && wndconfig->clientAPI == GLFW_OPENGL_API && wndconfig->glProfile == GLFW_OPENGL_ANY_PROFILE && diff --git a/src/x11_window.c b/src/x11_window.c index ac78a1544..f5fba1b36 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -129,8 +129,8 @@ static GLboolean createWindow(_GLFWwindow* window, if (wndconfig->monitor == NULL) { // HACK: This is a workaround for windows without a background pixel - // not getting any decorations on certain older versions of Compiz - // running on Intel hardware + // not getting any decorations on certain older versions of + // Compiz running on Intel hardware wa.background_pixel = BlackPixel(_glfw.x11.display, _glfw.x11.screen); wamask |= CWBackPixel; @@ -258,6 +258,9 @@ static GLboolean createWindow(_GLFWwindow* window, } else { + // HACK: Explicitly setting PPosition to any value causes some WMs, + // notably Compiz and Metacity, to honor the position of + // unmapped windows set by XMoveWindow hints->flags |= PPosition; hints->x = hints->y = 0; } @@ -275,7 +278,7 @@ static GLboolean createWindow(_GLFWwindow* window, // Set ICCCM WM_CLASS property // HACK: Until a mechanism for specifying the application name is added, the - // initial window title is used as the window class name + // initial window title is used as the window class name if (strlen(wndconfig->title)) { XClassHint* hint = XAllocClassHint(); From adbd52ba27f1aca79c2f1407b5276b08413cc5ee Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 10 Nov 2013 14:03:07 +0100 Subject: [PATCH 13/52] Formatted todos and notes. --- src/context.c | 4 ++-- src/glx_context.c | 4 ++-- src/nsgl_context.m | 2 +- src/win32_window.c | 2 +- src/x11_window.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/context.c b/src/context.c index 9279af8e2..a2e872ba3 100644 --- a/src/context.c +++ b/src/context.c @@ -425,7 +425,7 @@ GLboolean _glfwRefreshContextAttribs(void) if (glfwExtensionSupported("GL_ARB_robustness")) { // NOTE: We avoid using the context flags for detection, as they are - // only present from 3.0 while the extension applies from 1.1 + // only present from 3.0 while the extension applies from 1.1 GLint strategy; glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy); @@ -442,7 +442,7 @@ GLboolean _glfwRefreshContextAttribs(void) if (glfwExtensionSupported("GL_EXT_robustness")) { // NOTE: The values of these constants match those of the OpenGL ARB - // one, so we can reuse them here + // one, so we can reuse them here GLint strategy; glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy); diff --git a/src/glx_context.c b/src/glx_context.c index 824ffab34..47ae653fb 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -457,8 +457,8 @@ int _glfwCreateContext(_GLFWwindow* window, if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0) { // NOTE: Only request an explicitly versioned context when - // necessary, as explicitly requesting version 1.0 does not always - // return the highest available version + // necessary, as explicitly requesting version 1.0 does not + // always return the highest available version setGLXattrib(GLX_CONTEXT_MAJOR_VERSION_ARB, wndconfig->glMajor); setGLXattrib(GLX_CONTEXT_MINOR_VERSION_ARB, wndconfig->glMinor); diff --git a/src/nsgl_context.m b/src/nsgl_context.m index 1051fe7de..71638ad19 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -178,7 +178,7 @@ int _glfwCreateContext(_GLFWwindow* window, } // NOTE: All NSOpenGLPixelFormats on the relevant cards support sRGB - // frambuffer, so there's no need (and no way) to request it + // frambuffer, so there's no need (and no way) to request it ADD_ATTR(0); diff --git a/src/win32_window.c b/src/win32_window.c index 7480f70c0..21690d3f9 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -145,7 +145,7 @@ static int translateKey(WPARAM wParam, LPARAM lParam) { // Check for numeric keypad keys // NOTE: This way we always force "NumLock = ON", which is intentional since - // the returned key code should correspond to a physical location. + // the returned key code should correspond to a physical location. if ((HIWORD(lParam) & 0x100) == 0) { switch (MapVirtualKey(HIWORD(lParam) & 0xFF, 1)) diff --git a/src/x11_window.c b/src/x11_window.c index f5fba1b36..cb04a7803 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -150,7 +150,7 @@ static GLboolean createWindow(_GLFWwindow* window, if (!window->x11.handle) { // TODO: Handle all the various error codes here and translate them - // to GLFW errors + // to GLFW errors _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to create window"); return GL_FALSE; From bc625b21b3fff0813b920538a3aa2056d7192bab Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 10 Nov 2013 14:03:34 +0100 Subject: [PATCH 14/52] Removed completed todo. --- src/cocoa_window.m | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 24a41fa02..817019412 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -266,7 +266,6 @@ static int translateFlags(NSUInteger flags) static int translateKey(unsigned int key) { // Keyboard symbol translation table - // TODO: Need to find mappings for F13-F15, volume down/up/mute, and eject. static const unsigned int table[128] = { /* 00 */ GLFW_KEY_A, From 76afd4172727892286fe5728580021a26d198c49 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 10 Nov 2013 14:12:07 +0100 Subject: [PATCH 15/52] Added X error reporting to window creation failure. --- src/x11_window.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index cb04a7803..115ab1df2 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -136,6 +136,8 @@ static GLboolean createWindow(_GLFWwindow* window, wamask |= CWBackPixel; } + _glfwGrabXErrorHandler(); + window->x11.handle = XCreateWindow(_glfw.x11.display, _glfw.x11.root, 0, 0, @@ -147,12 +149,12 @@ static GLboolean createWindow(_GLFWwindow* window, wamask, &wa); + _glfwReleaseXErrorHandler(); + if (!window->x11.handle) { - // TODO: Handle all the various error codes here and translate them - // to GLFW errors - - _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to create window"); + _glfwInputXError(GLFW_PLATFORM_ERROR, + "X11: Failed to create window"); return GL_FALSE; } From d82095d7ea28d92e7e81803e527cd3366014e293 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 10 Nov 2013 15:43:25 +0100 Subject: [PATCH 16/52] Changed from PREFIX to CMAKE_INSTALL_PREFIX. --- docs/compile.dox | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/compile.dox b/docs/compile.dox index 6a51f62bd..39a65d556 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -135,9 +135,9 @@ GNU/Linux have this tool in a separate `cmake-curses-gui` package. `BUILD_SHARED_LIBS` determines whether GLFW is built as a static library or as a DLL / shared library / dynamic library. -`LIB_SUFFIX` affects where the GLFW shared /dynamic library is -installed. If it is empty, it is installed to `$PREFIX/lib`. If it is set to -`64`, it is installed to `$PREFIX/lib64`. +`LIB_SUFFIX` affects where the GLFW shared /dynamic library is installed. If it +is empty, it is installed to `${CMAKE_INSTALL_PREFIX}/lib`. If it is set to +`64`, it is installed to `${CMAKE_INSTALL_PREFIX}/lib64`. `GLFW_CLIENT_LIBRARY` determines which client API library to use. If set to `opengl` the OpenGL library is used, if set to `glesv1` for the OpenGL ES 1.x From 7af99bce88045405bd248b35ad5e80ea621e9aac Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 13 Nov 2013 12:19:43 +0100 Subject: [PATCH 17/52] Fixed cursor centering for odd window sizes. --- README.md | 1 + src/win32_platform.h | 2 +- src/win32_window.c | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3400a59e6..f9fe3a011 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ guide in the GLFW documentation. focus callback - [Win32] Bugfix: The disabled cursor mode clip rectangle was updated for unfocused windows + - [Win32] Bugfix: Cursor was not properly re-centered over odd-sized windows - [Cocoa] Added dependency on CoreVideo framework for refresh rate retrieval - [Cocoa] Enabled Lion full screen for resizable windowed mode windows - [Cocoa] Moved to Cocoa API for application transformation and activation diff --git a/src/win32_platform.h b/src/win32_platform.h index 69038651d..11d774b71 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -157,7 +157,7 @@ typedef struct _GLFWwindowWin32 GLboolean cursorCentered; GLboolean cursorInside; GLboolean cursorHidden; - double oldCursorX, oldCursorY; + int oldCursorX, oldCursorY; } _GLFWwindowWin32; diff --git a/src/win32_window.c b/src/win32_window.c index 21690d3f9..d90bd3320 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -604,7 +604,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (newCursorX != window->win32.oldCursorX || newCursorY != window->win32.oldCursorY) { - double x, y; + int x, y; if (window->cursorMode == GLFW_CURSOR_DISABLED) { @@ -1121,8 +1121,8 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos) ClientToScreen(window->win32.handle, &pos); SetCursorPos(pos.x, pos.y); - window->win32.oldCursorX = xpos; - window->win32.oldCursorY = ypos; + window->win32.oldCursorX = (int) xpos; + window->win32.oldCursorY = (int) ypos; } void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) From 109e3d13edfd2e0fdfdf1964a0f1362f44b4068a Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 13 Nov 2013 12:34:43 +0100 Subject: [PATCH 18/52] Fixed reporting of negative window positions. MSDN recommends LOWORD and HIWORD for WM_MOVE, but these do not handle negative window positions correctly. Fixes #172. --- README.md | 1 + src/win32_window.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f9fe3a011..2146db9e1 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ guide in the GLFW documentation. - [Win32] Bugfix: The disabled cursor mode clip rectangle was updated for unfocused windows - [Win32] Bugfix: Cursor was not properly re-centered over odd-sized windows + - [Win32] Bugfix: Negative window positions were reported incorrectly - [Cocoa] Added dependency on CoreVideo framework for refresh rate retrieval - [Cocoa] Enabled Lion full screen for resizable windowed mode windows - [Cocoa] Moved to Cocoa API for application transformation and activation diff --git a/src/win32_window.c b/src/win32_window.c index d90bd3320..30fc1668e 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -684,7 +684,9 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, updateClipRect(window); } - _glfwInputWindowPos(window, LOWORD(lParam), HIWORD(lParam)); + _glfwInputWindowPos(window, + GET_X_LPARAM(lParam), + GET_Y_LPARAM(lParam)); return 0; } From a5b6a306ae1216a67d5fa1f062cfdaee4ee7b815 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 13 Nov 2013 12:47:44 +0100 Subject: [PATCH 19/52] Added note. --- src/win32_window.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/win32_window.c b/src/win32_window.c index 30fc1668e..f98400210 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -684,6 +684,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, updateClipRect(window); } + // NOTE: This cannot use LOWORD/HIWORD recommended by MSDN, as + // those macros do not handle negative window positions correctly _glfwInputWindowPos(window, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); From 4fe88a52fae958d9c07610960757bad309560e9c Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 13 Nov 2013 12:59:49 +0100 Subject: [PATCH 20/52] Added credit. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2146db9e1..7ef7d89b8 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,7 @@ skills. - Jon Morton - Pierre Moulon - Julian Møller + - Kamil Nowakowski - Ozzy - Andri Pálsson - Peoro From a79b93f5bcf7bd76309a4234370d84d5665059d9 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 14 Nov 2013 12:59:08 +0100 Subject: [PATCH 21/52] Avoid X11 video mode setting if modes match. This matches the behavior of the Windows port. --- src/x11_monitor.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/x11_monitor.c b/src/x11_monitor.c index de3287cd5..48d47b4ae 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -111,6 +111,9 @@ void _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired) } } + if (bestMode == ci->mode) + return; + if (monitor->x11.oldMode == None) monitor->x11.oldMode = ci->mode; From 45368f410ace3c995e0eb3160d4f6230e4379da6 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 14 Nov 2013 13:42:29 +0100 Subject: [PATCH 22/52] Fixed warnings from Clang static analysis. --- examples/heightmap.c | 2 +- tests/glfwinfo.c | 3 --- tests/modes.c | 3 --- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/examples/heightmap.c b/examples/heightmap.c index 5ae50bfd5..c39e6b80c 100644 --- a/examples/heightmap.c +++ b/examples/heightmap.c @@ -644,7 +644,7 @@ int main(int argc, char** argv) /* main loop */ frame = 0; iter = 0; - dt = last_update_time = glfwGetTime(); + last_update_time = glfwGetTime(); while (!glfwWindowShouldClose(window)) { diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index ed7b9df60..fc312dee6 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -253,9 +253,6 @@ int main(int argc, char** argv) } } - argc -= optind; - argv += optind; - // Initialize GLFW and create window if (!valid_version()) diff --git a/tests/modes.c b/tests/modes.c index 37e9a6758..76353685c 100644 --- a/tests/modes.c +++ b/tests/modes.c @@ -218,9 +218,6 @@ int main(int argc, char** argv) } } - argc -= optind; - argv += optind; - glfwSetErrorCallback(error_callback); if (!glfwInit()) From 95c7029e1912eba716b754b807be6c7845ba9ba1 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 18 Nov 2013 12:06:39 +0100 Subject: [PATCH 23/52] Formatting. --- src/context.c | 2 +- src/window.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/context.c b/src/context.c index a2e872ba3..5545278a4 100644 --- a/src/context.c +++ b/src/context.c @@ -98,7 +98,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) if (wndconfig->clientAPI == GLFW_OPENGL_API) { - if (wndconfig->glMajor < 1 || wndconfig->glMinor < 0 || + if ((wndconfig->glMajor < 1 || wndconfig->glMinor < 0) || (wndconfig->glMajor == 1 && wndconfig->glMinor > 5) || (wndconfig->glMajor == 2 && wndconfig->glMinor > 1) || (wndconfig->glMajor == 3 && wndconfig->glMinor > 3)) diff --git a/src/window.c b/src/window.c index de75952b2..4e2b27701 100644 --- a/src/window.c +++ b/src/window.c @@ -213,10 +213,10 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, window->videoMode.refreshRate = Max(_glfw.hints.refreshRate, 0); } - window->monitor = wndconfig.monitor; - window->resizable = wndconfig.resizable; - window->decorated = wndconfig.decorated; - window->cursorMode = GLFW_CURSOR_NORMAL; + window->monitor = wndconfig.monitor; + window->resizable = wndconfig.resizable; + window->decorated = wndconfig.decorated; + window->cursorMode = GLFW_CURSOR_NORMAL; // Save the currently current context so it can be restored later previous = (_GLFWwindow*) glfwGetCurrentContext(); From 87e6417353d8b2f485362650a56cac7f3f67334c Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 18 Nov 2013 12:14:51 +0100 Subject: [PATCH 24/52] Added hack detecting ARB_compatibility. --- src/context.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/context.c b/src/context.c index 5545278a4..3bc86bc50 100644 --- a/src/context.c +++ b/src/context.c @@ -419,6 +419,14 @@ GLboolean _glfwRefreshContextAttribs(void) window->glProfile = GLFW_OPENGL_COMPAT_PROFILE; else if (mask & GL_CONTEXT_CORE_PROFILE_BIT) window->glProfile = GLFW_OPENGL_CORE_PROFILE; + else if (glfwExtensionSupported("GL_ARB_compatibility")) + { + // HACK: This is a workaround for the compatibility profile bit + // not being set in the context flags if an OpenGL 3.2+ + // context was created without having requested a specific + // version + window->glProfile = GLFW_OPENGL_COMPAT_PROFILE; + } } // Read back robustness strategy From bb3f29d8bca3bbcf4ad639ca9a8b66f32705e6dd Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 19 Nov 2013 17:57:08 +0100 Subject: [PATCH 25/52] Added note on profile detection. --- docs/window.dox | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/window.dox b/docs/window.dox index 8a28958a7..4af43091d 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -448,7 +448,9 @@ context is an OpenGL debug context, or `GL_FALSE` otherwise. The `GLFW_OPENGL_PROFILE` attribute indicates the OpenGL profile used by the context. This is `GLFW_OPENGL_CORE_PROFILE` or `GLFW_OPENGL_COMPAT_PROFILE` if the context uses a known profile, or `GLFW_OPENGL_ANY_PROFILE` if the -OpenGL profile is unknown or the context is for another client API. +OpenGL profile is unknown or the context is for another client API. Note that +the returned profile may not match the profile bits of the context flags, as +GLFW will try other means of detecting the profile when no bits are set. The `GLFW_CONTEXT_ROBUSTNESS` attribute indicates the robustness strategy used by the context. This is `GLFW_LOSE_CONTEXT_ON_RESET` or From 23021422f3c00f1a07c4d28fcc2a0d2ca15ec66d Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 20 Nov 2013 11:49:44 +0100 Subject: [PATCH 26/52] Added explicit configuration header macro. --- README.md | 2 ++ src/CMakeLists.txt | 2 ++ src/internal.h | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ef7d89b8..33aa99c34 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ guide in the GLFW documentation. - Added the `GLFW_BUILD_DOCS` CMake option for controlling whether the documentation is built + - Added the `_GLFW_USE_CONFIG_H` configuration macro for controlling whether to + include the configuration header - Renamed configuration header to `glfw_config.h` to avoid conflicts - Bugfix: The `glfw3.pc` file did not respect the `LIB_SUFFIX` CMake option - Bugfix: The `joysticks` test would segfault if a controller had no axes diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8c78ad203..cd699efdd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,6 +3,8 @@ include_directories(${GLFW_SOURCE_DIR}/src ${GLFW_BINARY_DIR}/src ${glfw_INCLUDE_DIRS}) +add_definitions(-D_GLFW_USE_CONFIG_H) + set(common_HEADERS ${GLFW_BINARY_DIR}/src/glfw_config.h internal.h ${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h ${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h) diff --git a/src/internal.h b/src/internal.h index 357277eb3..763c150f2 100644 --- a/src/internal.h +++ b/src/internal.h @@ -29,7 +29,9 @@ #define _internal_h_ -#include "glfw_config.h" +#if defined(_GLFW_USE_CONFIG_H) + #include "glfw_config.h" +#endif #if defined(_GLFW_USE_OPENGL) // This is the default for glfw3.h From 0ccbddf7676c42aa9cfb3842d27f66bd04e6aa34 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 20 Nov 2013 13:58:57 +0100 Subject: [PATCH 27/52] Moved version number macro to internal.h. This lets alternative build environments avoid having to manually keep track of which version of GLFW is being built. --- README.md | 1 + src/cocoa_init.m | 2 +- src/glfw_config.h.in | 3 --- src/internal.h | 2 ++ src/win32_init.c | 2 +- src/x11_init.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 33aa99c34..46321e0e0 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ guide in the GLFW documentation. documentation is built - Added the `_GLFW_USE_CONFIG_H` configuration macro for controlling whether to include the configuration header + - Moved version number macro to `internal.h` for easier manual compilation - Renamed configuration header to `glfw_config.h` to avoid conflicts - Bugfix: The `glfw3.pc` file did not respect the `LIB_SUFFIX` CMake option - Bugfix: The `joysticks` test would segfault if a controller had no axes diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 9c2813f88..42b31c54e 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -122,7 +122,7 @@ void _glfwPlatformTerminate(void) const char* _glfwPlatformGetVersionString(void) { - const char* version = _GLFW_VERSION_FULL " Cocoa" + const char* version = _GLFW_VERSION_NUMBER " Cocoa" #if defined(_GLFW_NSGL) " NSGL" #endif diff --git a/src/glfw_config.h.in b/src/glfw_config.h.in index ea65a9430..a7318602e 100644 --- a/src/glfw_config.h.in +++ b/src/glfw_config.h.in @@ -81,6 +81,3 @@ // Define this to 1 if using OpenGL ES 2.0 as the client library #cmakedefine _GLFW_USE_GLESV2 -// The GLFW version as used by glfwGetVersionString -#define _GLFW_VERSION_FULL "@GLFW_VERSION_FULL@" - diff --git a/src/internal.h b/src/internal.h index 763c150f2..e5f29e255 100644 --- a/src/internal.h +++ b/src/internal.h @@ -33,6 +33,8 @@ #include "glfw_config.h" #endif +#define _GLFW_VERSION_NUMBER "3.0.4" + #if defined(_GLFW_USE_OPENGL) // This is the default for glfw3.h #elif defined(_GLFW_USE_GLESV1) diff --git a/src/win32_init.c b/src/win32_init.c index 8e0c19b0b..e9101fb60 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -243,7 +243,7 @@ void _glfwPlatformTerminate(void) const char* _glfwPlatformGetVersionString(void) { - const char* version = _GLFW_VERSION_FULL " Win32" + const char* version = _GLFW_VERSION_NUMBER " Win32" #if defined(_GLFW_WGL) " WGL" #elif defined(_GLFW_EGL) diff --git a/src/x11_init.c b/src/x11_init.c index 3d94ff5eb..269314cb7 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -680,7 +680,7 @@ void _glfwPlatformTerminate(void) const char* _glfwPlatformGetVersionString(void) { - const char* version = _GLFW_VERSION_FULL " X11" + const char* version = _GLFW_VERSION_NUMBER " X11" #if defined(_GLFW_GLX) " GLX" #elif defined(_GLFW_EGL) From 8b1b32277130efddce4303eafa4ccee86889be07 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 20 Nov 2013 14:27:05 +0100 Subject: [PATCH 28/52] Added manual compilation guide. --- docs/compile.dox | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/docs/compile.dox b/docs/compile.dox index 39a65d556..e06bcefd2 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -190,4 +190,71 @@ systems. context creation API. Note that EGL is not yet provided on all supported platforms. + +@section compile_manual Compiling GLFW manually + +If you wish to compile GLFW without its CMake build environment then you will +have to do at least some of the platform detection yourself. GLFW needs +a number of configuration macros to be defined in order to know what it's being +compiled for and has many optional, platform-specific ones for various features. + +When building with CMake, the `glfw_config.h` configuration header is generated +based on the current platform and CMake options. The GLFW CMake environment +defines `_GLFW_USE_CONFIG_H`, which causes this header to be included by +`internal.h`. Without this macro, GLFW will expect the necessary configuration +macros to be defined on the command-line. + +Three macros *must* be defined when compiling GLFW: one for selecting the window +creation API, one selecting the context creation API and one client library. +Exactly one of each kind must be defined for GLFW to compile and link. + +The window creation API is used to create windows, handle input, monitors, gamma +ramps and clipboard. The options are: + + - `_GLFW_COCOA` to use the Cocoa frameworks + - `_GLFW_WIN32` to use the Win32 API + - `_GLFW_X11` to use the X Window System + +The context creation API is used to enumerate pixel formats / framebuffer +configurations and to create contexts. The options are: + + - `_GLFW_NSGL` to use the Cocoa OpenGL framework + - `_GLFW_WGL` to use the Win32 WGL API + - `_GLFW_GLX` to use the X11 GLX API + - `_GLFW_EGL` to use the EGL API + +The client library is the one providing the OpenGL or OpenGL ES API, which is +used by GLFW to probe the created context. This is not the same thing as the +client API, as many desktop OpenGL client libraries now expose the OpenGL ES API +through extensions. The options are: + + - `_GLFW_USE_OPENGL` for the desktop OpenGL + - `_GLFW_USE_GLESV1` for OpenGL ES 1.x + - `_GLFW_USE_GLESV2` for OpenGL ES 2.x + +Note that `_GLFW_USE_GLESV1` and `_GLFW_USE_GLESV2` may only be used with EGL, +as the other context creation APIs do not interface with + +If you are building GLFW as a shared library / dynamic library / DLL then you +must also define `_GLFW_BUILD_DLL`. Otherwise, you may not define it. + +If you are using the X11 window creation API then you *must* also select an entry +point retrieval mechanism. + + - `_GLFW_HAS_GLXGETPROCADDRESS` to use glXGetProcAddress (recommended) + - `_GLFW_HAS_GLXGETPROCADDRESSARB` to use glXGetProcAddressARB + - `_GLFW_HAS_GLXGETPROCADDRESSEXT` to use glXGetProcAddressEXT + - `_GLFW_HAS_DLOPEN` to do manual retrieval with `dlopen` + +On modern systems it is usually safe to assume that +`_GLFW_HAS_GLXGETPROCADDRESS` is present. + +If you are using the Cocoa window creation API, the following options are +available: + + - `_GLFW_USE_CHDIR` to `chdir` into the `Resources` directory of the + application bundle during @ref glfwInit (recommended) + - `_GLFW_USE_MENUBAR` to create and populate the menu bar when the first window + is created (recommended) + */ From 9979da59e39a5aaffb0690d5a30849a2ef4a7f48 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 20 Nov 2013 14:32:45 +0100 Subject: [PATCH 29/52] Manual compilation guide work. --- docs/compile.dox | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/docs/compile.dox b/docs/compile.dox index e06bcefd2..5bcea6284 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -221,19 +221,21 @@ configurations and to create contexts. The options are: - `_GLFW_NSGL` to use the Cocoa OpenGL framework - `_GLFW_WGL` to use the Win32 WGL API - `_GLFW_GLX` to use the X11 GLX API - - `_GLFW_EGL` to use the EGL API + - `_GLFW_EGL` to use the EGL API (experimental) The client library is the one providing the OpenGL or OpenGL ES API, which is used by GLFW to probe the created context. This is not the same thing as the client API, as many desktop OpenGL client libraries now expose the OpenGL ES API through extensions. The options are: - - `_GLFW_USE_OPENGL` for the desktop OpenGL - - `_GLFW_USE_GLESV1` for OpenGL ES 1.x - - `_GLFW_USE_GLESV2` for OpenGL ES 2.x + - `_GLFW_USE_OPENGL` for the desktop OpenGL (opengl32.dll, libGL.so or + OpenGL.framework) + - `_GLFW_USE_GLESV1` for OpenGL ES 1.x (experimental) + - `_GLFW_USE_GLESV2` for OpenGL ES 2.x (experimental) Note that `_GLFW_USE_GLESV1` and `_GLFW_USE_GLESV2` may only be used with EGL, -as the other context creation APIs do not interface with +as the other context creation APIs do not interface with OpenGL ES client +libraries. If you are building GLFW as a shared library / dynamic library / DLL then you must also define `_GLFW_BUILD_DLL`. Otherwise, you may not define it. @@ -241,18 +243,15 @@ must also define `_GLFW_BUILD_DLL`. Otherwise, you may not define it. If you are using the X11 window creation API then you *must* also select an entry point retrieval mechanism. - - `_GLFW_HAS_GLXGETPROCADDRESS` to use glXGetProcAddress (recommended) - - `_GLFW_HAS_GLXGETPROCADDRESSARB` to use glXGetProcAddressARB - - `_GLFW_HAS_GLXGETPROCADDRESSEXT` to use glXGetProcAddressEXT - - `_GLFW_HAS_DLOPEN` to do manual retrieval with `dlopen` - -On modern systems it is usually safe to assume that -`_GLFW_HAS_GLXGETPROCADDRESS` is present. + - `_GLFW_HAS_GLXGETPROCADDRESS` to use `glXGetProcAddress` (recommended) + - `_GLFW_HAS_GLXGETPROCADDRESSARB` to use `glXGetProcAddressARB` (legacy) + - `_GLFW_HAS_GLXGETPROCADDRESSEXT` to use `glXGetProcAddressEXT` (legacy) + - `_GLFW_HAS_DLOPEN` to do manual retrieval with `dlopen` (fallback) If you are using the Cocoa window creation API, the following options are available: - - `_GLFW_USE_CHDIR` to `chdir` into the `Resources` directory of the + - `_GLFW_USE_CHDIR` to `chdir` to the `Resources` subdirectory of the application bundle during @ref glfwInit (recommended) - `_GLFW_USE_MENUBAR` to create and populate the menu bar when the first window is created (recommended) From 2db0401a57a8005b58ffc474200d7f63539f1633 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 20 Nov 2013 15:08:53 +0100 Subject: [PATCH 30/52] Removed excuse. --- include/GLFW/glfw3.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 4bf47dedc..354878bf5 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -863,9 +863,6 @@ typedef struct GLFWgammaramp * * @note This function may only be called from the main thread. * - * @note This function may take several seconds to complete on some systems, - * while on other systems it may take only a fraction of a second to complete. - * * @note **OS X:** This function will change the current directory of the * application to the `Contents/Resources` subdirectory of the application's * bundle, if present. From c21745c8865f6b9bf9c6c004464cfe6405556a34 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 20 Nov 2013 15:28:30 +0100 Subject: [PATCH 31/52] Added reference to manual compilation guide. --- docs/compile.dox | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/compile.dox b/docs/compile.dox index 5bcea6284..ef6c3b931 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -19,6 +19,8 @@ Windows and OS X from the [CMake website](http://www.cmake.org/). Additional dependencies are listed below. +If you wish to compile GLFW without CMake, see @ref compile_manual. + @subsection compile_deps_msvc Dependencies using Visual C++ on Windows From 171538d01c6add6a81a67c878dd854ce78be017a Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 20 Nov 2013 15:33:40 +0100 Subject: [PATCH 32/52] Grammar fix. --- docs/news.dox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/news.dox b/docs/news.dox index 6f97afc89..ef794fdb2 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -79,7 +79,7 @@ through CMake options. GLFW now supports high-DPI monitors on both Windows and OS X, giving windows full resolution framebuffers where other UI elements are scaled up. To achieve this, @ref glfwGetFramebufferSize and @ref glfwSetFramebufferSizeCallback have been -added. These work with pixels, while the rest of the GLFW API work with screen +added. These work with pixels, while the rest of the GLFW API works with screen coordinates. From e0ee90d50c19f41822a8e7ca3f8fe09c8a1dc41a Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 20 Nov 2013 15:37:08 +0100 Subject: [PATCH 33/52] Fixed news item tag name. --- docs/news.dox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/news.dox b/docs/news.dox index ef794fdb2..bbce25fd1 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -18,7 +18,7 @@ For more information on how to use CMake, see the [CMake manual](http://cmake.org/cmake/help/documentation.html). -@subsection new_30_multiwnd Multi-window support +@subsection news_30_multiwnd Multi-window support GLFW now supports the creation of multiple windows, each with their own OpenGL or OpenGL ES context, and all window functions now take a window handle. Event From 5ef4f77fb5bc559f019fbbcf343735bcf1213934 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 20 Nov 2013 19:58:06 +0100 Subject: [PATCH 34/52] Added support for _NET_WM_BYPASS_COMPOSITOR. --- README.md | 1 + src/x11_init.c | 2 ++ src/x11_platform.h | 1 + src/x11_window.c | 18 ++++++++++++++++++ 4 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 46321e0e0..16f7b0f06 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ guide in the GLFW documentation. - [Cocoa] Bugfix: Controllers were reported as having zero buttons and axes - [Cocoa] Bugfix: Removed joystick axis value negation left over from GLFW 2 - [X11] Added setting of the `WM_CLASS` property to the initial window title + - [X11] Added support for `_NET_WM_BYPASS_COMPOSITOR` - [X11] Bugfix: Removed joystick axis value negation left over from GLFW 2 - [X11] Bugfix: The position of hidden windows was ignored by Metacity and Compiz diff --git a/src/x11_init.c b/src/x11_init.c index 269314cb7..5b477f045 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -409,6 +409,8 @@ static void detectEWMH(void) getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_PING"); _glfw.x11.NET_ACTIVE_WINDOW = getSupportedAtom(supportedAtoms, atomCount, "_NET_ACTIVE_WINDOW"); + _glfw.x11.NET_WM_BYPASS_COMPOSITOR = + getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_BYPASS_COMPOSITOR"); XFree(supportedAtoms); diff --git a/src/x11_platform.h b/src/x11_platform.h index 868429fa9..f8129385b 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -117,6 +117,7 @@ typedef struct _GLFWlibraryX11 Atom NET_WM_PING; Atom NET_WM_STATE; Atom NET_WM_STATE_FULLSCREEN; + Atom NET_WM_BYPASS_COMPOSITOR; Atom NET_ACTIVE_WINDOW; Atom MOTIF_WM_HINTS; diff --git a/src/x11_window.c b/src/x11_window.c index 115ab1df2..164f10700 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -399,6 +399,15 @@ static void enterFullscreenMode(_GLFWwindow* window) _glfwSetVideoMode(window->monitor, &window->videoMode); + if (_glfw.x11.NET_WM_BYPASS_COMPOSITOR != None) + { + const unsigned long value = 1; + + XChangeProperty(_glfw.x11.display, window->x11.handle, + _glfw.x11.NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32, + PropModeReplace, (unsigned char*) &value, 1); + } + if (_glfw.x11.hasEWMH && _glfw.x11.NET_WM_STATE != None && _glfw.x11.NET_WM_STATE_FULLSCREEN != None) @@ -487,6 +496,15 @@ static void leaveFullscreenMode(_GLFWwindow* window) _glfw.x11.saver.exposure); } + if (_glfw.x11.NET_WM_BYPASS_COMPOSITOR != None) + { + const unsigned long value = 0; + + XChangeProperty(_glfw.x11.display, window->x11.handle, + _glfw.x11.NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32, + PropModeReplace, (unsigned char*) &value, 1); + } + if (_glfw.x11.hasEWMH && _glfw.x11.NET_WM_STATE != None && _glfw.x11.NET_WM_STATE_FULLSCREEN != None) From 823cc38ac1c8a39c4bb363fe6773f76c0aed8a22 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 20 Nov 2013 20:04:00 +0100 Subject: [PATCH 35/52] Cleanup. --- src/x11_window.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index 164f10700..53960481f 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -205,13 +205,13 @@ static GLboolean createWindow(_GLFWwindow* window, // The WM_DELETE_WINDOW ICCCM protocol // Basic window close notification protocol - if (_glfw.x11.WM_DELETE_WINDOW != None) + if (_glfw.x11.WM_DELETE_WINDOW) protocols[count++] = _glfw.x11.WM_DELETE_WINDOW; // The _NET_WM_PING EWMH protocol // Tells the WM to ping the GLFW window and flag the application as // unresponsive if the WM doesn't get a reply within a few seconds - if (_glfw.x11.NET_WM_PING != None) + if (_glfw.x11.NET_WM_PING) protocols[count++] = _glfw.x11.NET_WM_PING; if (count > 0) @@ -221,7 +221,7 @@ static GLboolean createWindow(_GLFWwindow* window, } } - if (_glfw.x11.NET_WM_PID != None) + if (_glfw.x11.NET_WM_PID) { const pid_t pid = getpid(); @@ -399,7 +399,7 @@ static void enterFullscreenMode(_GLFWwindow* window) _glfwSetVideoMode(window->monitor, &window->videoMode); - if (_glfw.x11.NET_WM_BYPASS_COMPOSITOR != None) + if (_glfw.x11.NET_WM_BYPASS_COMPOSITOR) { const unsigned long value = 1; @@ -408,15 +408,13 @@ static void enterFullscreenMode(_GLFWwindow* window) PropModeReplace, (unsigned char*) &value, 1); } - if (_glfw.x11.hasEWMH && - _glfw.x11.NET_WM_STATE != None && - _glfw.x11.NET_WM_STATE_FULLSCREEN != None) + if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN) { int x, y; _glfwPlatformGetMonitorPos(window->monitor, &x, &y); _glfwPlatformSetWindowPos(window, x, y); - if (_glfw.x11.NET_ACTIVE_WINDOW != None) + if (_glfw.x11.NET_ACTIVE_WINDOW) { // Ask the window manager to raise and focus the GLFW window // Only focused windows with the _NET_WM_STATE_FULLSCREEN state end @@ -496,7 +494,7 @@ static void leaveFullscreenMode(_GLFWwindow* window) _glfw.x11.saver.exposure); } - if (_glfw.x11.NET_WM_BYPASS_COMPOSITOR != None) + if (_glfw.x11.NET_WM_BYPASS_COMPOSITOR) { const unsigned long value = 0; @@ -505,9 +503,7 @@ static void leaveFullscreenMode(_GLFWwindow* window) PropModeReplace, (unsigned char*) &value, 1); } - if (_glfw.x11.hasEWMH && - _glfw.x11.NET_WM_STATE != None && - _glfw.x11.NET_WM_STATE_FULLSCREEN != None) + if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN) { // Ask the window manager to make the GLFW window a normal window // Normal windows usually have frames and other decorations @@ -735,7 +731,7 @@ static void processEvent(XEvent *event) _glfwInputWindowCloseRequest(window); } - else if (_glfw.x11.NET_WM_PING != None && + else if (_glfw.x11.NET_WM_PING && (Atom) event->xclient.data.l[0] == _glfw.x11.NET_WM_PING) { // The window manager is pinging the application to ensure it's @@ -1017,7 +1013,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) NULL, NULL, NULL); #endif - if (_glfw.x11.NET_WM_NAME != None) + if (_glfw.x11.NET_WM_NAME) { XChangeProperty(_glfw.x11.display, window->x11.handle, _glfw.x11.NET_WM_NAME, _glfw.x11.UTF8_STRING, 8, @@ -1025,7 +1021,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) (unsigned char*) title, strlen(title)); } - if (_glfw.x11.NET_WM_ICON_NAME != None) + if (_glfw.x11.NET_WM_ICON_NAME) { XChangeProperty(_glfw.x11.display, window->x11.handle, _glfw.x11.NET_WM_ICON_NAME, _glfw.x11.UTF8_STRING, 8, @@ -1042,7 +1038,7 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) XTranslateCoordinates(_glfw.x11.display, window->x11.handle, _glfw.x11.root, 0, 0, &x, &y, &child); - if (child != None) + if (child) { int left, top; From 84438486379efa201200b40b5b728deac1e43cdb Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 24 Nov 2013 23:31:15 +0100 Subject: [PATCH 36/52] Updated swap interval notes. --- docs/window.dox | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/window.dox b/docs/window.dox index 4af43091d..ab83e5054 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -487,8 +487,10 @@ zero can be useful for benchmarking purposes, when it is not desirable to measure the time it takes to wait for the vertical retrace. However, a swap interval of one lets you avoid tearing. -Note that not all OpenGL implementations properly implement this function, in -which case @ref glfwSwapInterval will have no effect. Some drivers also have -user settings that override requests by GLFW. +Note that this may not work on all machines, as some drivers have +user-controlled settings that override any swap interval the application +requests. It is also by default disabled on Windows Vista and later when using +DWM (Aero), as using it there sometimes leads to severe jitter. You can +forcibly enable it for machines using DWM using @ref compile_options_win32. */ From 06289110e79ad5d0f166be7355cdeddd1323af94 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 24 Nov 2013 23:31:26 +0100 Subject: [PATCH 37/52] Documented utility functions. --- src/internal.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/internal.h b/src/internal.h index e5f29e255..8a24959a3 100644 --- a/src/internal.h +++ b/src/internal.h @@ -754,11 +754,18 @@ void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size); */ void _glfwFreeGammaArrays(GLFWgammaramp* ramp); -/*! @ingroup utility +/*! @brief Allocates and returns a monitor object with the specified name + * and dimensions. + * @param[in] name The name of the monitor. + * @param[in] widthMM The width, in mm, of the monitor's display area. + * @param[in] heightMM The height, in mm, of the monitor's display area. + * @return The newly created object. + * @ingroup utility */ _GLFWmonitor* _glfwCreateMonitor(const char* name, int widthMM, int heightMM); -/*! @ingroup utility +/*! @brief Frees a monitor object and any data associated with it. + * @ingroup utility */ void _glfwDestroyMonitor(_GLFWmonitor* monitor); From ed98e06651a932f45438e9c790f18a12caeb8524 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 4 Dec 2013 05:35:36 +0100 Subject: [PATCH 38/52] Clarified WGL missing OpenGL error. --- src/wgl_context.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/wgl_context.c b/src/wgl_context.c index ccd7f574b..6e7d50305 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -272,9 +272,21 @@ static GLboolean choosePixelFormat(_GLFWwindow* window, usableCount++; } + if (!usableCount) + { + _glfwInputError(GLFW_API_UNAVAILABLE, + "WGL: The driver does not appear to support OpenGL"); + + free(usableConfigs); + return GL_FALSE; + } + closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount); if (!closest) { + _glfwInputError(GLFW_PLATFORM_ERROR, + "WGL: Failed to find a suitable pixel format"); + free(usableConfigs); return GL_FALSE; } @@ -355,11 +367,7 @@ int _glfwCreateContext(_GLFWwindow* window, } if (!choosePixelFormat(window, fbconfig, &pixelFormat)) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "WGL: Failed to find a suitable pixel format"); return GL_FALSE; - } if (!DescribePixelFormat(window->wgl.dc, pixelFormat, sizeof(pfd), &pfd)) { From 0c0bb28d39b2f4a0b48ab447a37564e23d651d55 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 4 Dec 2013 08:00:53 +0100 Subject: [PATCH 39/52] Allow setting swap interval to zero on DWM. --- README.md | 1 + src/wgl_context.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 16f7b0f06..7cd6f31e4 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ guide in the GLFW documentation. - Renamed configuration header to `glfw_config.h` to avoid conflicts - Bugfix: The `glfw3.pc` file did not respect the `LIB_SUFFIX` CMake option - Bugfix: The `joysticks` test would segfault if a controller had no axes + - [Win32] Allowed swap interval to be explicitly set to zero on DWM systems - [Win32] Bugfix: Removed joystick axis value negation left over from GLFW 2 - [Win32] Bugfix: Restoring windows using the Win+D hot key did not trigger the focus callback diff --git a/src/wgl_context.c b/src/wgl_context.c index 6e7d50305..0b3610bd9 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -606,7 +606,7 @@ void _glfwPlatformSwapInterval(int interval) _GLFWwindow* window = _glfwPlatformGetCurrentContext(); #if !defined(_GLFW_USE_DWM_SWAP_INTERVAL) - if (_glfwIsCompositionEnabled()) + if (_glfwIsCompositionEnabled() && interval) { // Don't enabled vsync when desktop compositing is enabled, as it leads // to frame jitter From 2ae46fa90a192e31ef76aa4fa0bca31743c4e12f Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 4 Dec 2013 19:12:24 +0100 Subject: [PATCH 40/52] Added notes on window refresh. --- include/GLFW/glfw3.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 354878bf5..e8f24f126 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1691,6 +1691,12 @@ GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window * This function is no longer called by @ref glfwSwapBuffers. You need to call * it or @ref glfwWaitEvents yourself. * + * @remarks On some platforms, a window move, resize or menu operation will + * cause event processing to block. This is due to how event processing is + * designed on those platforms. You can use the + * [window refresh callback](@ref GLFWwindowrefreshfun) to redraw the contents + * of your window when necessary during the operation. + * * @note This function may only be called from the main thread. * * @note This function may not be called from a callback. @@ -1718,6 +1724,12 @@ GLFWAPI void glfwPollEvents(void); * * This function is not required for joystick input to work. * + * @remarks On some platforms, a window move, resize or menu operation will + * cause event processing to block. This is due to how event processing is + * designed on those platforms. You can use the + * [window refresh callback](@ref GLFWwindowrefreshfun) to redraw the contents + * of your window when necessary during the operation. + * * @note This function may only be called from the main thread. * * @note This function may not be called from a callback. From 56e600d7a14a37e0b2c180c24d61dd378845db78 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 5 Dec 2013 02:15:14 +0100 Subject: [PATCH 41/52] Fixed iconify callback not triggered by Alt+Tab. --- README.md | 2 ++ src/win32_window.c | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/README.md b/README.md index 7cd6f31e4..1ef8b7fa2 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,8 @@ guide in the GLFW documentation. unfocused windows - [Win32] Bugfix: Cursor was not properly re-centered over odd-sized windows - [Win32] Bugfix: Negative window positions were reported incorrectly + - [Win32] Bugfix: The iconify callback was not triggered when switching away + from a full screen window using Alt+Tab - [Cocoa] Added dependency on CoreVideo framework for refresh rate retrieval - [Cocoa] Enabled Lion full screen for resizable windowed mode windows - [Cocoa] Moved to Cocoa API for application transformation and activation diff --git a/src/win32_window.c b/src/win32_window.c index f98400210..32b6ff210 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -442,6 +442,19 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, return 0; } + case WM_ACTIVATEAPP: + { + if (!wParam && IsIconic(hWnd)) + { + // This is a workaround for full screen windows losing focus + // through Alt+Tab leading to windows being told they're + // unfocused and restored and then never told they're iconified + _glfwInputWindowIconify(window, GL_TRUE); + } + + return 0; + } + case WM_SHOWWINDOW: { _glfwInputWindowVisibility(window, wParam ? GL_TRUE : GL_FALSE); From 5668eb0732a21b7e6e463531d93bc24bdf6bd149 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 5 Dec 2013 03:15:35 +0100 Subject: [PATCH 42/52] Added paragraph on object sharing. --- docs/context.dox | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/context.dox b/docs/context.dox index 56d1de768..8057cc704 100644 --- a/docs/context.dox +++ b/docs/context.dox @@ -24,6 +24,15 @@ what kind of context is created. See [context related hints](@ref window_hints_ctx) in the window handling guide. +@section context_sharing Context object sharing + +When creating a window and context with @ref glfwCreateWindow, you can specify +another window whose context the new one should share its objects with. OpenGL +object sharing is implemented by the operating system and graphics driver and is +described in the OpenGL documentation. On platforms where it is possible to +choose which types of objects are shared, GLFW requests that all are shared. + + @section context_current Current context Before you can use the OpenGL or OpenGL ES APIs, you need to have a current From a18b1874947e625f4a0e5c0af8993b0107e32970 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 5 Dec 2013 03:27:12 +0100 Subject: [PATCH 43/52] Expanded cursor mode descriptions. --- include/GLFW/glfw3.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index e8f24f126..0f97738c7 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1765,9 +1765,12 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode); * modes: * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally. * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the client - * area of the window. - * - `GLFW_CURSOR_DISABLED` disables the cursor and removes any limitations on - * cursor movement. + * area of the window but does not restrict the cursor from leaving. This is + * useful if you wish to render your own cursor or have no visible cursor at + * all. + * - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual + * and unlimited cursor movement. This is useful for implementing for + * example 3D camera controls. * * If `mode` is `GLFW_STICKY_KEYS`, the value must be either `GL_TRUE` to * enable sticky keys, or `GL_FALSE` to disable it. If sticky keys are From 50c694fab451aca299345b96f4551743b18bf734 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 8 Dec 2013 14:59:52 +0100 Subject: [PATCH 44/52] Added errors for override redirect iconification. --- src/x11_window.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/x11_window.c b/src/x11_window.c index 53960481f..03aee2835 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1119,6 +1119,9 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window) { // Override-redirect windows cannot be iconified or restored, as those // tasks are performed by the window manager + _glfwInputError(GLFW_API_UNAVAILABLE, + "X11: Iconification of full screen windows requires " + "a WM that supports EWMH"); return; } @@ -1131,6 +1134,9 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window) { // Override-redirect windows cannot be iconified or restored, as those // tasks are performed by the window manager + _glfwInputError(GLFW_API_UNAVAILABLE, + "X11: Iconification of full screen windows requires " + "a WM that supports EWMH"); return; } From 61ccb034d01662d4df3adfb96aa8a4113facec39 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 9 Dec 2013 00:27:36 +0100 Subject: [PATCH 45/52] Formatting. --- src/x11_window.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index 03aee2835..7f7569503 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1178,10 +1178,8 @@ void _glfwPlatformWaitEvents(void) { if (!XPending(_glfw.x11.display)) { - int fd; fd_set fds; - - fd = ConnectionNumber(_glfw.x11.display); + const int fd = ConnectionNumber(_glfw.x11.display); FD_ZERO(&fds); FD_SET(fd, &fds); From 402189ba1437d380e4836ecdba6940bf37fe7894 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 10 Dec 2013 00:46:06 +0100 Subject: [PATCH 46/52] Fixed pthread.h not included by GLX header. --- README.md | 2 ++ src/glx_context.c | 1 - src/glx_platform.h | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ef8b7fa2..9e7ce539d 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,8 @@ guide in the GLFW documentation. - [X11] Bugfix: Removed joystick axis value negation left over from GLFW 2 - [X11] Bugfix: The position of hidden windows was ignored by Metacity and Compiz + - [X11] Bugfix: The `pthread.h` header was not included by the GLX platform + header. ## Contact diff --git a/src/glx_context.c b/src/glx_context.c index 47ae653fb..6b87000da 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -30,7 +30,6 @@ #include #include #include -#include // This is the only glXGetProcAddress variant not declared by glxext.h diff --git a/src/glx_platform.h b/src/glx_platform.h index 74e60a81c..4b133a2d4 100644 --- a/src/glx_platform.h +++ b/src/glx_platform.h @@ -41,6 +41,8 @@ #include #endif +#include + // We support four different ways for getting addresses for GL/GLX // extension functions: glXGetProcAddress, glXGetProcAddressARB, // glXGetProcAddressEXT, and dlsym From 0108a6bdeb3ff8f48ff460486169d32989251ac3 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 10 Dec 2013 13:45:21 +0100 Subject: [PATCH 47/52] Added credit. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9e7ce539d..a5722256c 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,7 @@ skills. - Jonathan Dummer - Ralph Eastwood - Gerald Franz + - Michael Fogleman - GeO4d - Marcus Geelnard - Stefan Gustavson From 8ac7cab100b4749d75cae5e693c94ef2b71d96e7 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 11 Dec 2013 14:38:27 +0100 Subject: [PATCH 48/52] Added notes on API headers. --- docs/build.dox | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/build.dox b/docs/build.dox index 86ec1e5f8..60a1df631 100644 --- a/docs/build.dox +++ b/docs/build.dox @@ -50,7 +50,9 @@ header that the GLFW header includes and GLEW will work as expected. @subsection build_macros GLFW header option macros These macros may be defined before the inclusion of the GLFW header and affect -how that header behaves. +the behavior of the header. Note that GLFW does not provide any of the OpenGL +or OpenGL ES headers mentioned below. These are provided by your development +environment or your OpenGL or OpenGL ES SDK. `GLFW_INCLUDE_GLCOREARB` makes the header include the modern `GL/glcorearb.h` header (`OpenGL/gl3.h` on OS X) instead of the regular OpenGL header. From cf458fa7a2e0add285820b43739f36561ed2c850 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 11 Dec 2013 14:41:51 +0100 Subject: [PATCH 49/52] Formatting. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a5722256c..7d30fa2c3 100644 --- a/README.md +++ b/README.md @@ -125,8 +125,8 @@ skills. - Paul R. Deppe - Jonathan Dummer - Ralph Eastwood - - Gerald Franz - Michael Fogleman + - Gerald Franz - GeO4d - Marcus Geelnard - Stefan Gustavson From 4eea3175f184317d8193bb127a6d40ff3ac3d44f Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 18 Dec 2013 12:42:05 +0100 Subject: [PATCH 50/52] Re-worded OS X context creation limits. --- docs/compat.dox | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/compat.dox b/docs/compat.dox index 9f78f476e..e14263f6d 100644 --- a/docs/compat.dox +++ b/docs/compat.dox @@ -123,15 +123,15 @@ version 2.1. Because of this, on OS X 10.7 and later, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` hints will cause @ref glfwCreateWindow to fail if -given version 3.0 or 3.1, the `GLFW_OPENGL_FORWARD_COMPAT` is required for -creating contexts for OpenGL 3.2 and later, the `GLFW_OPENGL_DEBUG_CONTEXT` hint -is ignored and setting the `GLFW_OPENGL_PROFILE` hint to anything except -`GLFW_OPENGL_CORE_PROFILE` will cause @ref glfwCreateWindow to fail. +given version 3.0 or 3.1, the `GLFW_OPENGL_FORWARD_COMPAT` hint must be set to +non-zero and the `GLFW_OPENGL_PROFILE` hint must be set to +`GLFW_OPENGL_CORE_PROFILE` when creating OpenGL 3.2 and later contexts and the +`GLFW_OPENGL_DEBUG_CONTEXT` hint is ignored. Also, on Mac OS X 10.6 and below, the `GLFW_CONTEXT_VERSION_MAJOR` and -`GLFW_CONTEXT_VERSION_MINOR` hints will fail if given a version above 2.1, the -`GLFW_OPENGL_DEBUG_CONTEXT` hint will have no effect, and setting the -`GLFW_OPENGL_PROFILE` or `GLFW_OPENGL_FORWARD_COMPAT` hints to a non-zero value -will cause @ref glfwCreateWindow to fail. +`GLFW_CONTEXT_VERSION_MINOR` hints will fail if given a version above 2.1, +setting the `GLFW_OPENGL_PROFILE` or `GLFW_OPENGL_FORWARD_COMPAT` hints to +a non-default value will cause @ref glfwCreateWindow to fail and the +`GLFW_OPENGL_DEBUG_CONTEXT` hint is ignored. */ From b17bed28c8105e6543df558a34b1ad9a63dbc89c Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 23 Dec 2013 00:52:28 +0100 Subject: [PATCH 51/52] Added note on gdi32 as non-defaultlib on MinGW. Some versions of MinGW do not include gdi32 among the default libraries for Win32 subsystem binaries. --- docs/build.dox | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/build.dox b/docs/build.dox index 60a1df631..c4594cda8 100644 --- a/docs/build.dox +++ b/docs/build.dox @@ -85,8 +85,10 @@ The static version of the GLFW library is named `glfw3`. When using this version, it is also necessary to link with some libraries that GLFW uses. When linking a program under Windows that uses the static version of GLFW, you -must link with `opengl32`. If you are using GLU, you must also link with -`glu32`. +must link with `opengl32`. On some versions of MinGW, you must also explicitly +link with `gdi32`, while other versions of MinGW include it in the set of +default libraries along with other dependencies like `user32` and `kernel32`. +If you are using GLU, you must also link with `glu32`. The link library for the GLFW DLL is named `glfw3dll`. When compiling a program that uses the DLL version of GLFW, you need to define the `GLFW_DLL` macro From 0e8dace18c9d592a6f37a5238137edd1a6d41f53 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 24 Dec 2013 00:48:28 +0100 Subject: [PATCH 52/52] Removed stray whitespace in version string. --- src/win32_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win32_init.c b/src/win32_init.c index e9101fb60..aae46a9b8 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -252,7 +252,7 @@ const char* _glfwPlatformGetVersionString(void) #if defined(__MINGW32__) " MinGW" #elif defined(_MSC_VER) - " VisualC " + " VisualC" #elif defined(__BORLANDC__) " BorlandC" #endif