From e6556c7f34a8e4f232fa6df0166d279e3d05c60e Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 17 Oct 2012 17:11:56 +0200 Subject: [PATCH 1/4] Comment grammar fix. --- src/cocoa_window.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index e3a88901..dc33f165 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -654,9 +654,9 @@ static GLboolean initializeAppKit(void) // Implicitly create shared NSApplication instance [GLFWApplication sharedApplication]; - // Setting up the menu bar must go between sharedApplication - // above and finishLaunching below, in order to properly emulate the - // behavior of NSApplicationMain + // Menu bar setup must go between sharedApplication above and + // finishLaunching below, in order to properly emulate the behavior + // of NSApplicationMain createMenuBar(); [NSApp finishLaunching]; From c1dcd29c71daca0db02e0158a87af54eac62b969 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 21 Oct 2012 21:30:13 +0200 Subject: [PATCH 2/4] Fixed potential clearing of wrong context. --- src/cocoa_window.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 1ecc9655..5625d41d 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -969,7 +969,9 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) [window->NSGL.pixelFormat release]; window->NSGL.pixelFormat = nil; - [NSOpenGLContext clearCurrentContext]; + if ([NSOpenGLContext currentContext] == window->NSGL.context) + [NSOpenGLContext clearCurrentContext]; + [window->NSGL.context release]; window->NSGL.context = nil; From 467d5016210cc8f13b6bde7812df7ea773a3dd79 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 21 Oct 2012 21:57:29 +0200 Subject: [PATCH 3/4] Cleanup of context clearing during window destruction. --- src/cocoa_window.m | 3 --- src/win32_opengl.c | 5 ----- src/win32_window.c | 8 ++++++++ src/window.c | 4 ++-- src/x11_opengl.c | 2 -- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index c01582c1..fd60d0ee 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -969,9 +969,6 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) [window->NSGL.pixelFormat release]; window->NSGL.pixelFormat = nil; - if ([NSOpenGLContext currentContext] == window->NSGL.context) - [NSOpenGLContext clearCurrentContext]; - [window->NSGL.context release]; window->NSGL.context = nil; diff --git a/src/win32_opengl.c b/src/win32_opengl.c index c326dac7..acbf09f5 100644 --- a/src/win32_opengl.c +++ b/src/win32_opengl.c @@ -528,11 +528,6 @@ int _glfwCreateContext(_GLFWwindow* window, void _glfwDestroyContext(_GLFWwindow* window) { - // This is duplicated from glfwDestroyWindow - // TODO: Stop duplicating code - if (window == _glfwCurrentWindow) - _glfwPlatformMakeContextCurrent(NULL); - if (window->WGL.context) { wglDeleteContext(window->WGL.context); diff --git a/src/win32_window.c b/src/win32_window.c index 6b275476..6bb9509d 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -947,8 +947,16 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, // we're just creating an OpenGL 3.0+ context with the same pixel // format, but it's not worth the added code complexity + // First we clear the current context (the one we just created) + // This is usually done by glfwDestroyWindow, but as we're not doing + // full window destruction, it's duplicated here + _glfwPlatformMakeContextCurrent(NULL); + + // Next destroy the Win32 window and WGL context (without resetting or + // destroying the GLFW window object) destroyWindow(window); + // ...and then create them again, this time with better APIs if (!createWindow(window, wndconfig, fbconfig)) return GL_FALSE; } diff --git a/src/window.c b/src/window.c index 741938d1..bb1093f5 100644 --- a/src/window.c +++ b/src/window.c @@ -483,8 +483,8 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow handle) if (window == NULL) return; - // Clear the current context if this window's context is current - // TODO: Re-examine this in light of multithreading + // The window's context must not be current on another thread when the + // window is destroyed if (window == _glfwPlatformGetCurrentContext()) _glfwPlatformMakeContextCurrent(NULL); diff --git a/src/x11_opengl.c b/src/x11_opengl.c index 19e04a4f..ccd59d87 100644 --- a/src/x11_opengl.c +++ b/src/x11_opengl.c @@ -619,8 +619,6 @@ void _glfwDestroyContext(_GLFWwindow* window) if (window->GLX.context) { - // Release and destroy the context - glXMakeCurrent(_glfwLibrary.X11.display, None, NULL); glXDestroyContext(_glfwLibrary.X11.display, window->GLX.context); window->GLX.context = NULL; } From bf43247aedab5262677373e93890d806ea10dc37 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 21 Oct 2012 22:13:14 +0200 Subject: [PATCH 4/4] Fixed output of GLFW-parsed context profile by glfwinfo. --- tests/glfwinfo.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index 1fa9fa2f..3b262852 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -74,7 +74,7 @@ static const char* get_client_api_name(int api) return "Unknown API"; } -static const char* get_profile_name(GLint mask) +static const char* get_profile_name_gl(GLint mask) { if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) return "compatibility"; @@ -84,6 +84,16 @@ static const char* get_profile_name(GLint mask) return "unknown"; } +static const char* get_profile_name_glfw(int profile) +{ + if (profile == GLFW_OPENGL_COMPAT_PROFILE) + return "compatibility"; + if (profile == GLFW_OPENGL_CORE_PROFILE) + return "core"; + + return "unknown"; +} + static void list_extensions(int api, int major, int minor) { int i; @@ -302,13 +312,17 @@ int main(int argc, char** argv) if (major > 3 || (major == 3 && minor >= 2)) { + int profile = glfwGetWindowParam(window, GLFW_OPENGL_PROFILE); + glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask); printf("%s profile mask (0x%08x): %s\n", get_client_api_name(api), mask, - get_profile_name(mask)); + get_profile_name_gl(mask)); - printf("%s profile mask parsed by GLFW:\n", get_client_api_name(api)); + printf("%s profile mask parsed by GLFW: %s\n", + get_client_api_name(api), + get_profile_name_glfw(profile)); } }