浏览代码

Merge branch 'master' into multi-monitor

Camilla Berglund 13 年之前
父节点
当前提交
0e170f4902
共有 6 个文件被更改,包括 30 次插入16 次删除
  1. 3 4
      src/cocoa_window.m
  2. 0 5
      src/win32_opengl.c
  3. 8 0
      src/win32_window.c
  4. 2 2
      src/window.c
  5. 0 2
      src/x11_opengl.c
  6. 17 3
      tests/glfwinfo.c

+ 3 - 4
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];
@@ -969,7 +969,6 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
     [window->NSGL.pixelFormat release];
     window->NSGL.pixelFormat = nil;
 
-    [NSOpenGLContext clearCurrentContext];
     [window->NSGL.context release];
     window->NSGL.context = nil;
 

+ 0 - 5
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);

+ 8 - 0
src/win32_window.c

@@ -964,8 +964,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;
     }

+ 2 - 2
src/window.c

@@ -477,8 +477,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);
 

+ 0 - 2
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;
     }

+ 17 - 3
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));
         }
     }