Просмотр исходного кода

Cocoa: Improve OpenGL version restriction messages

Fixes #904.
Camilla Löwy 8 лет назад
Родитель
Сommit
fd127d59fa
3 измененных файлов с 18 добавлено и 11 удалено
  1. 7 0
      docs/window.dox
  2. 7 0
      include/GLFW/glfw3.h
  3. 4 11
      src/nsgl_context.m

+ 7 - 0
docs/window.dox

@@ -299,6 +299,13 @@ cannot be returned if 2.0 or later was requested, and vice versa.  This is
 because OpenGL ES 3.x is backward compatible with 2.0, but OpenGL ES 2.0 is not
 backward compatible with 1.x.
 
+@note @macos The OS only supports forward-compatible core profile contexts for
+OpenGL versions 3.2 and later.  Before creating an OpenGL context of version
+3.2 or later you must set the `GLFW_OPENGL_FORWARD_COMPAT` and
+`GLFW_OPENGL_PROFILE` hints accordingly.  OpenGL 3.0 and 3.1 contexts are not
+supported at all on macOS.
+
+
 `GLFW_OPENGL_FORWARD_COMPAT` specifies whether the OpenGL context should be
 forward-compatible, i.e. one where all functionality deprecated in the requested
 version of OpenGL is removed.  This must only be used if the requested OpenGL

+ 7 - 0
include/GLFW/glfw3.h

@@ -1831,6 +1831,13 @@ GLFWAPI void glfwWindowHint(int hint, int value);
  *  @remark @win32 The context to share resources with must not be current on
  *  any other thread.
  *
+ *  @remark @macos The OS only supports forward-compatible core profile contexts
+ *  for OpenGL versions 3.2 and later.  Before creating an OpenGL context of
+ *  version 3.2 or later you must set the
+ *  [GLFW_OPENGL_FORWARD_COMPAT](@ref window_hints_ctx) and
+ *  [GLFW_OPENGL_PROFILE](@ref window_hints_ctx) accordingly.  OpenGL 3.0 and
+ *  3.1 contexts are not supported at all on macOS.
+ *
  *  @remark @macos The GLFW window has no icon, as it is not a document
  *  window, but the dock icon will be the same as the application bundle's icon.
  *  For more information on bundles, see the

+ 4 - 11
src/nsgl_context.m

@@ -128,26 +128,19 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
         return GLFW_FALSE;
     }
 
-    if (ctxconfig->major == 3 && ctxconfig->minor < 2)
-    {
-        _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                        "NSGL: The targeted version of macOS does not support OpenGL 3.0 or 3.1");
-        return GLFW_FALSE;
-    }
-
     if (ctxconfig->major > 2)
     {
-        if (!ctxconfig->forward)
+        if (ctxconfig->major == 3 && ctxconfig->minor < 2)
         {
             _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                            "NSGL: The targeted version of macOS only supports forward-compatible contexts for OpenGL 3.2 and above");
+                            "NSGL: The targeted version of macOS does not support OpenGL 3.0 or 3.1 (but may support 3.3 and above)");
             return GLFW_FALSE;
         }
 
-        if (ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE)
+        if (!ctxconfig->forward || ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE)
         {
             _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                            "NSGL: The targeted version of macOS only supports core profile contexts for OpenGL 3.2 and above");
+                            "NSGL: The targeted version of macOS only supports forward-compatible core profile contexts for OpenGL 3.2 and above");
             return GLFW_FALSE;
         }
     }