Browse Source

Merge branch 'master' into multi-monitor

Conflicts:
	include/GL/glfw3.h
	src/window.c
	tests/glfwinfo.c
Camilla Berglund 12 năm trước cách đây
mục cha
commit
692f34b536

+ 61 - 12
include/GL/glfw3.h

@@ -459,88 +459,124 @@ extern "C" {
  *  @{ */
 
 /*! @brief @c GL_TRUE if the window has focus, or @c GL_FALSE otherwise.
+ *  @see glfwGetWindowParam
  */
 #define GLFW_FOCUSED              0x00020001
 /*! @brief @c GL_TRUE if the window is iconified, or @c GL_FALSE otherwise.
+ *  @see glfwGetWindowParam
  */
 #define GLFW_ICONIFIED            0x00020002
 /*! @brief @c GL_TRUE if the window has been requested to close, or @c GL_FALSE
  *  otherwise.
+ *  @see glfwGetWindowParam
  */
 #define GLFW_CLOSE_REQUESTED      0x00020003
 /*! @brief The client API version revision.
+ *  @see glfwGetWindowParam
  */
 #define GLFW_CONTEXT_REVISION      0x00020004
 
 /*! @brief The bit depth of the red component of the color buffer.
+ *  @see glfwWindowHint
  */
 #define GLFW_RED_BITS             0x00021000
 /*! @brief The bit depth of the green component of the color buffer.
+ *  @see glfwWindowHint
  */
 #define GLFW_GREEN_BITS           0x00021001
 /*! @brief The bit depth of the blue component of the color buffer.
+ *  @see glfwWindowHint
  */
 #define GLFW_BLUE_BITS            0x00021002
 /*! @brief The bit depth of the alpha component of the color buffer.
+ *  @see glfwWindowHint
  */
 #define GLFW_ALPHA_BITS           0x00021003
 /*! @brief The bit depth of the depth buffer of the default framebuffer.
+ *  @see glfwWindowHint
  */
 #define GLFW_DEPTH_BITS           0x00021004
 /*! @brief The bit depth of the stencil buffer of the default framebuffer.
+ *  @see glfwWindowHint
  */
 #define GLFW_STENCIL_BITS         0x00021005
 /*! @brief The monitor refresh rate.
+ *  @see glfwWindowHint glfwGetWindowParam
  */
 #define GLFW_REFRESH_RATE         0x00021006
 /*! @brief The bit depth of the red component of the accumulation buffer.
+ *  @see glfwWindowHint
  */
 #define GLFW_ACCUM_RED_BITS       0x00021007
 /*! @brief The bit depth of the red component of the accumulation buffer.
+ *  @see glfwWindowHint
  */
 #define GLFW_ACCUM_GREEN_BITS     0x00021008
 /*! @brief The bit depth of the red component of the accumulation buffer.
+ *  @see glfwWindowHint
  */
 #define GLFW_ACCUM_BLUE_BITS      0x00021009
 /*! @brief The bit depth of the red component of the accumulation buffer.
+ *  @see glfwWindowHint
  */
 #define GLFW_ACCUM_ALPHA_BITS     0x0002100A
 /*! @brief The number of auxiliary buffers.
+ *  @see glfwWindowHint
  */
 #define GLFW_AUX_BUFFERS          0x0002100B
 /*! @brief @c GL_TRUE for stereo rendering, or @c GL_FALSE otherwise.
+ *  @see glfwWindowHint
  */
 #define GLFW_STEREO               0x0002100C
 /*! @brief The number of samples used for default framebuffer multisampling, or
  *  zero to disable multisampling.
+ *  @see glfwWindowHint
  */
 #define GLFW_FSAA_SAMPLES         0x0002100E
 /*! @brief @c GL_TRUE if the framebuffer should be sRGB capable, or @c GL_FALSE
  *  otherwise.
+ *  @see glfwWindowHint
  */
 #define GLFW_SRGB_CAPABLE         0x0002100F
 
 /*! @brief The @link clients client API @endlink to create a context for.
+ *  @see glfwWindowHint glfwGetWindowParam
  */
 #define GLFW_CLIENT_API           0x00022000
+/*! @see glfwWindowHint glfwGetWindowParam
+ */
 #define GLFW_CONTEXT_VERSION_MAJOR 0x00022001
+/*! @see glfwWindowHint glfwGetWindowParam
+ */
 #define GLFW_CONTEXT_VERSION_MINOR 0x00022002
+/*! @see glfwWindowHint glfwGetWindowParam
+ */
 #define GLFW_CONTEXT_ROBUSTNESS   0x00022003
+/*! @see glfwWindowHint glfwGetWindowParam
+ */
 #define GLFW_OPENGL_FORWARD_COMPAT 0x00022004
+/*! @see glfwWindowHint glfwGetWindowParam
+ */
 #define GLFW_OPENGL_DEBUG_CONTEXT 0x00022005
+/*! @see glfwWindowHint glfwGetWindowParam
+ */
 #define GLFW_OPENGL_PROFILE       0x00022006
 /*! @brief @c GL_TRUE if the window is resizable, or @c GL_FALSE otherwise.
+ *  @see glfwWindowHint glfwGetWindowParam
  */
 #define GLFW_RESIZABLE            0x00022007
 /*! @brief @c GL_TRUE if the window is visible, or @c GL_FALSE otherwise.
+ *  @see glfwWindowHint glfwGetWindowParam
  */
 #define GLFW_VISIBLE              0x00022008
 /*! @brief The x-coordinate, in pixels, of the upper-left corner of the
  *  client area of the window.
+ *  @see glfwWindowHint glfwGetWindowParam
  */
 #define GLFW_POSITION_X           0x00022009
 /*! @brief The y-coordinate, in pixels, of the upper-left corner of the
  *  client area of the window.
+ *  @see glfwWindowHint glfwGetWindowParam
  */
 #define GLFW_POSITION_Y           0x0002200A
 
@@ -1082,6 +1118,8 @@ GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp);
  *  The @ref GLFW_CONTEXT_VERSION_MAJOR and @ref GLFW_CONTEXT_VERSION_MINOR
  *  hints are set to 1 and 0, respectively.
  *
+ *  The @ref GLFW_CONTEXT_ROBUSTNESS hint is set to @ref GLFW_NO_ROBUSTNESS.
+ *
  *  All other hints are set to 0.
  *
  *  @ingroup window
@@ -1102,8 +1140,10 @@ GLFWAPI void glfwDefaultWindowHints(void);
  *  specify the desired bit depths of the various components of the default
  *  framebuffer.
  *
- *  The @ref GLFW_REFRESH_RATE hint specifies the desired monitor refresh rate
- *  for fullscreen windows.
+ *  The @ref GLFW_REFRESH_RATE hint specifies the desired monitor refresh rate,
+ *  in Hz, of the video mode for a fullscreen window, or zero to let the system
+ *  choose a suitable refresh rate.  If a windowed mode window is created, this
+ *  hint is ignored.
  *
  *  The @ref GLFW_ACCUM_RED_BITS, @ref GLFW_ACCUM_GREEN_BITS, @ref
  *  GLFW_ACCUM_BLUE_BITS and @ref GLFW_ACCUM_ALPHA_BITS hints specify the
@@ -1137,17 +1177,23 @@ GLFWAPI void glfwDefaultWindowHints(void);
  *  For OpenGL ES, these hints are hard constraints, as there is no backward
  *  compatibility between OpenGL ES versions.
  *
- *  The @ref GLFW_OPENGL_FORWARD_COMPAT hint specifies whether the OpenGL
- *  context should be forward-compatible, i.e. one where all functionality
- *  deprecated in the requested version of OpenGL is removed.
+ *  If an OpenGL context is requested, the @ref GLFW_OPENGL_FORWARD_COMPAT hint
+ *  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 may only be used if the requested OpenGL version is 3.0 or
+ *  above.  If another client API is requested, this hint is ignored.
  *
- *  The @ref GLFW_OPENGL_DEBUG_CONTEXT hint specifies whether to create a debug
- *  OpenGL context, which may have additional error and performance issue
- *  reporting functionality.
+ *  If an OpenGL context is requested, the @ref GLFW_OPENGL_DEBUG_CONTEXT hint
+ *  specifies whether to create a debug OpenGL context, which may have
+ *  additional error and performance issue reporting functionality.  If another
+ *  client API is requested, this hint is ignored.
  *
- *  The @ref GLFW_OPENGL_PROFILE hint specifies which OpenGL profile to create
- *  the context for.  Possible values are @ref GLFW_OPENGL_NO_PROFILE, @ref
- *  GLFW_OPENGL_CORE_PROFILE and @ref GLFW_OPENGL_COMPAT_PROFILE.
+ *  If an OpenGL context is requested, the @ref GLFW_OPENGL_PROFILE hint
+ *  specifies which OpenGL profile to create the context for.  Possible values
+ *  are @ref GLFW_OPENGL_NO_PROFILE, @ref GLFW_OPENGL_CORE_PROFILE and @ref
+ *  GLFW_OPENGL_COMPAT_PROFILE.  This may only be used if the requested OpenGL
+ *  version is 3.2 or above.  If another client API is requested, this hint
+ *  is ignored.
  *
  *  The @ref GLFW_CONTEXT_ROBUSTNESS hint specifies the robustness strategy to
  *  be used by the context.
@@ -1169,9 +1215,12 @@ GLFWAPI void glfwDefaultWindowHints(void);
  *  find out the actual properties of the created window and context, use the
  *  @ref glfwGetWindowParam function.
  *
- *  The following window hints are hard constraints:
+ *  The following hints are hard constraints:
  *  @arg @ref GLFW_STEREO
  *  @arg @ref GLFW_CLIENT_API
+ *
+ *  The following additional hints are hard constraints if requesting an OpenGL
+ *  context:
  *  @arg @ref GLFW_OPENGL_FORWARD_COMPAT
  *  @arg @ref GLFW_OPENGL_PROFILE
  *

+ 1 - 2
src/cocoa_init.m

@@ -85,8 +85,7 @@ int _glfwPlatformInit(void)
         CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
     if (_glfwLibrary.NSGL.framework == NULL)
     {
-        _glfwSetError(GLFW_PLATFORM_ERROR,
-                      "glfwInit: Failed to locate OpenGL framework");
+        _glfwSetError(GLFW_PLATFORM_ERROR, "Failed to locate OpenGL framework");
         return GL_FALSE;
     }
 

+ 1 - 1
src/cocoa_window.m

@@ -731,7 +731,7 @@ static GLboolean createContext(_GLFWwindow* window,
     if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
     {
         _glfwSetError(GLFW_VERSION_UNAVAILABLE,
-                      "Cocoa/NSOpenGL: NSOpenGL does not support OpenGL ES");
+                      "NSOpenGL: This API does not support OpenGL ES");
         return GL_FALSE;
     }
 

+ 87 - 73
src/context.c

@@ -255,7 +255,6 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
 
 //========================================================================
 // Checks whether the client API part of the window config is sane
-// It blames glfwOpenWindow because that's the only caller
 //========================================================================
 
 GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
@@ -263,39 +262,25 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
     if (wndconfig->clientAPI != GLFW_OPENGL_API &&
         wndconfig->clientAPI != GLFW_OPENGL_ES_API)
     {
-        _glfwSetError(GLFW_INVALID_ENUM,
-                      "glfwCreateWindow: Invalid client API requested");
+        _glfwSetError(GLFW_INVALID_ENUM, "Invalid client API requested");
         return GL_FALSE;
     }
 
     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))
         {
             // OpenGL 1.0 is the smallest valid version
-            _glfwSetError(GLFW_INVALID_VALUE,
-                          "glfwCreateWindow: Invalid OpenGL version requested");
-            return GL_FALSE;
-        }
-        if (wndconfig->glMajor == 1 && wndconfig->glMinor > 5)
-        {
             // OpenGL 1.x series ended with version 1.5
-            _glfwSetError(GLFW_INVALID_VALUE,
-                          "glfwCreateWindow: Invalid OpenGL version requested");
-            return GL_FALSE;
-        }
-        else if (wndconfig->glMajor == 2 && wndconfig->glMinor > 1)
-        {
             // OpenGL 2.x series ended with version 2.1
-            _glfwSetError(GLFW_INVALID_VALUE,
-                          "glfwCreateWindow: Invalid OpenGL version requested");
-            return GL_FALSE;
-        }
-        else if (wndconfig->glMajor == 3 && wndconfig->glMinor > 3)
-        {
             // OpenGL 3.x series ended with version 3.3
+
             _glfwSetError(GLFW_INVALID_VALUE,
-                          "glfwCreateWindow: Invalid OpenGL version requested");
+                          "Invalid OpenGL version %i.%i requested",
+                          wndconfig->glMajor, wndconfig->glMinor);
             return GL_FALSE;
         }
         else
@@ -309,7 +294,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
                 wndconfig->glProfile != GLFW_OPENGL_COMPAT_PROFILE)
             {
                 _glfwSetError(GLFW_INVALID_ENUM,
-                              "glfwCreateWindow: Invalid OpenGL profile requested");
+                              "Invalid OpenGL profile requested");
                 return GL_FALSE;
             }
 
@@ -320,7 +305,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
                 // and above
 
                 _glfwSetError(GLFW_INVALID_VALUE,
-                              "glfwCreateWindow: Context profiles only exist for "
+                              "Context profiles only exist for "
                               "OpenGL version 3.2 and above");
                 return GL_FALSE;
             }
@@ -330,25 +315,24 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
         {
             // Forward-compatible contexts are only defined for OpenGL version 3.0 and above
             _glfwSetError(GLFW_INVALID_VALUE,
-                          "glfwCreateWindow: Forward compatibility only exist "
-                          "for OpenGL version 3.0 and above");
+                          "Forward compatibility only exist for OpenGL "
+                          "version 3.0 and above");
             return GL_FALSE;
         }
     }
     else if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
     {
-        if (wndconfig->glMajor < 1 || wndconfig->glMinor < 0)
+        if (wndconfig->glMajor < 1 || wndconfig->glMinor < 0 ||
+            (wndconfig->glMajor == 1 && wndconfig->glMinor > 1) ||
+            (wndconfig->glMajor == 2 && wndconfig->glMinor > 0))
         {
             // OpenGL ES 1.0 is the smallest valid version
-            _glfwSetError(GLFW_INVALID_VALUE,
-                          "glfwCreateWindow: Invalid OpenGL ES version requested");
-            return GL_FALSE;
-        }
-        if (wndconfig->glMajor == 1 && wndconfig->glMinor > 1)
-        {
             // OpenGL ES 1.x series ended with version 1.1
+            // OpenGL ES 2.x series ended with version 2.0
+
             _glfwSetError(GLFW_INVALID_VALUE,
-                          "glfwCreateWindow: Invalid OpenGL ES version requested");
+                          "Invalid OpenGL ES version %i.%i requested",
+                          wndconfig->glMajor, wndconfig->glMinor);
             return GL_FALSE;
         }
         else
@@ -360,8 +344,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
         {
             // OpenGL ES does not support profiles
             _glfwSetError(GLFW_INVALID_VALUE,
-                          "glfwCreateWindow: Context profiles are not supported "
-                          "by OpenGL ES");
+                          "Context profiles are not supported by OpenGL ES");
             return GL_FALSE;
         }
 
@@ -369,8 +352,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
         {
             // OpenGL ES does not support forward-compatibility
             _glfwSetError(GLFW_INVALID_VALUE,
-                          "glfwCreateWindow: Forward compatibility is not "
-                          "supported by OpenGL ES");
+                          "Forward compatibility is not supported by OpenGL ES");
             return GL_FALSE;
         }
     }
@@ -381,8 +363,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
             wndconfig->glRobustness != GLFW_LOSE_CONTEXT_ON_RESET)
         {
             _glfwSetError(GLFW_INVALID_VALUE,
-                          "glfwCreateWindow: Invalid OpenGL robustness mode "
-                          "requested");
+                          "Invalid OpenGL robustness mode requested");
             return GL_FALSE;
         }
     }
@@ -393,7 +374,6 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
 
 //========================================================================
 // Reads back context properties
-// It blames glfwCreateWindow because that's the only caller
 //========================================================================
 
 GLboolean _glfwRefreshContextParams(void)
@@ -418,41 +398,77 @@ GLboolean _glfwRefreshContextParams(void)
         if (!window->GetStringi)
         {
             _glfwSetError(GLFW_PLATFORM_ERROR,
-                          "glfwCreateWindow: Entry point retrieval is broken");
+                          "Entry point retrieval is broken");
             return GL_FALSE;
         }
     }
 
-    // Read back forward-compatibility flag
+    if (window->clientAPI == GLFW_OPENGL_API)
     {
-      window->glForward = GL_FALSE;
-
-      if (window->clientAPI == GLFW_OPENGL_API && window->glMajor >= 3)
-      {
-          GLint flags;
-          glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
-
-          if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
-              window->glForward = GL_TRUE;
-          if (flags & 0)
-              window->glDebug = GL_TRUE;
-      }
-    }
+        // Read back context flags (OpenGL 3.0 and above)
+        if (window->glMajor >= 3)
+        {
+            GLint flags;
+            glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
 
-    // Read back OpenGL context profile
+            if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
+                window->glForward = GL_TRUE;
+
+            if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
+                window->glDebug = GL_TRUE;
+            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
+                window->glDebug = GL_TRUE;
+            }
+        }
+
+        // Read back OpenGL context profile (OpenGL 3.2 and above)
+        if (window->glMajor > 3 ||
+            (window->glMajor == 3 && window->glMinor >= 2))
+        {
+            GLint mask;
+            glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
+
+            if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
+                window->glProfile = GLFW_OPENGL_COMPAT_PROFILE;
+            else if (mask & GL_CONTEXT_CORE_PROFILE_BIT)
+                window->glProfile = GLFW_OPENGL_CORE_PROFILE;
+        }
+
+        // Read back robustness strategy
+        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
+
+            GLint strategy;
+            glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
+
+            if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
+                window->glRobustness = GLFW_LOSE_CONTEXT_ON_RESET;
+            else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
+                window->glRobustness = GLFW_NO_RESET_NOTIFICATION;
+        }
+    }
+    else
     {
-      window->glProfile = 0;
-
-      if (window->glMajor > 3 || (window->glMajor == 3 && window->glMinor >= 2))
-      {
-          GLint mask;
-          glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
-
-          if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
-              window->glProfile = GLFW_OPENGL_COMPAT_PROFILE;
-          else if (mask & GL_CONTEXT_CORE_PROFILE_BIT)
-              window->glProfile = GLFW_OPENGL_CORE_PROFILE;
-      }
+        // Read back robustness strategy
+        if (glfwExtensionSupported("GL_EXT_robustness"))
+        {
+            // NOTE: The values of these constants match those of the OpenGL ARB
+            // one, so we can reuse them here
+
+            GLint strategy;
+            glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
+
+            if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
+                window->glRobustness = GLFW_LOSE_CONTEXT_ON_RESET;
+            else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
+                window->glRobustness = GLFW_NO_RESET_NOTIFICATION;
+        }
     }
 
     return GL_TRUE;
@@ -461,7 +477,6 @@ GLboolean _glfwRefreshContextParams(void)
 
 //========================================================================
 // Checks whether the current context fulfils the specified requirements
-// It blames glfwCreateWindow because that's the only caller
 //========================================================================
 
 GLboolean _glfwIsValidContext(_GLFWwndconfig* wndconfig)
@@ -479,8 +494,7 @@ GLboolean _glfwIsValidContext(_GLFWwndconfig* wndconfig)
         // For API consistency, we emulate the behavior of the
         // {GLX|WGL}_ARB_create_context extension and fail here
 
-        _glfwSetError(GLFW_VERSION_UNAVAILABLE,
-                      "glfwCreateWindow: The requested OpenGL version is not available");
+        _glfwSetError(GLFW_VERSION_UNAVAILABLE, NULL);
         return GL_FALSE;
     }
 

+ 55 - 44
src/egl_context.c

@@ -175,7 +175,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window,
 // Create the actual OpenGL(|ES) context
 //========================================================================
 
-#define setEGLattrib(attribs, index, attribName, attribValue) \
+#define setEGLattrib(attribName, attribValue) \
 { \
     attribs[index++] = attribName; \
     attribs[index++] = attribValue; \
@@ -186,7 +186,7 @@ static int createContext(_GLFWwindow* window,
                          EGLint fbconfigID)
 {
     int attribs[40];
-    EGLint count, index;
+    EGLint count;
     EGLConfig config;
     EGLContext share = NULL;
 
@@ -195,10 +195,10 @@ static int createContext(_GLFWwindow* window,
 
     // Retrieve the previously selected EGLConfig
     {
-        index = 0;
+        int index = 0;
 
-        setEGLattrib(attribs, index, EGL_CONFIG_ID, fbconfigID);
-        setEGLattrib(attribs, index, EGL_NONE, EGL_NONE);
+        setEGLattrib(EGL_CONFIG_ID, fbconfigID);
+        setEGLattrib(EGL_NONE, EGL_NONE);
 
         eglChooseConfig(_glfwLibrary.EGL.display, attribs, &config, 1, &count);
         if (!count)
@@ -209,10 +209,8 @@ static int createContext(_GLFWwindow* window,
         }
     }
 
-    // Retrieve the corresponding visual
-    // NOTE: This is the only non-portable code in this file.
-    // Maybe it would not hurt too much to add #ifdefs for different platforms?
 #if defined(_GLFW_X11)
+    // Retrieve the visual corresponding to the chosen EGL config
     {
         int mask;
         EGLint redBits, greenBits, blueBits, alphaBits, visualID = 0;
@@ -264,8 +262,7 @@ static int createContext(_GLFWwindow* window,
     {
         if (!eglBindAPI(EGL_OPENGL_ES_API))
         {
-            _glfwSetError(GLFW_PLATFORM_ERROR,
-                          "EGL: OpenGL ES is not supported");
+            _glfwSetError(GLFW_PLATFORM_ERROR, "EGL: OpenGL ES is not supported");
             return GL_FALSE;
         }
     }
@@ -273,66 +270,65 @@ static int createContext(_GLFWwindow* window,
     {
         if (!eglBindAPI(EGL_OPENGL_API))
         {
-            _glfwSetError(GLFW_PLATFORM_ERROR,
-                          "EGL: OpenGL is not supported");
+            _glfwSetError(GLFW_PLATFORM_ERROR, "EGL: OpenGL is not supported");
             return GL_FALSE;
         }
     }
 
-    index = 0;
-
     if (_glfwLibrary.EGL.KHR_create_context)
     {
-        setEGLattrib(attribs, index, EGL_CONTEXT_MAJOR_VERSION_KHR, wndconfig->glMajor);
-        setEGLattrib(attribs, index, EGL_CONTEXT_MINOR_VERSION_KHR, wndconfig->glMinor);
+        int index = 0, mask = 0, flags = 0, strategy = 0;
 
-        if (wndconfig->glForward || wndconfig->glDebug || wndconfig->glRobustness)
+        if (wndconfig->clientAPI == GLFW_OPENGL_API)
         {
-            int flags = 0;
+            if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
+                mask |= EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
+            else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
+                mask |= EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR;
 
             if (wndconfig->glForward)
                 flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
 
             if (wndconfig->glDebug)
                 flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
-
-            if (wndconfig->glRobustness)
-                flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
-
-            setEGLattrib(attribs, index, EGL_CONTEXT_FLAGS_KHR, flags);
         }
 
-        if (wndconfig->glProfile)
+        if (wndconfig->glRobustness != GLFW_NO_ROBUSTNESS)
         {
-            int flags = 0;
-
-            if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
-                flags = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
-            else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
-                flags = EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR;
-
-            setEGLattrib(attribs, index, EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, flags);
-        }
-
-        if (wndconfig->glRobustness)
-        {
-            int strategy;
-
             if (wndconfig->glRobustness == GLFW_NO_RESET_NOTIFICATION)
                 strategy = EGL_NO_RESET_NOTIFICATION_KHR;
             else if (wndconfig->glRobustness == GLFW_LOSE_CONTEXT_ON_RESET)
                 strategy = EGL_LOSE_CONTEXT_ON_RESET_KHR;
 
-            setEGLattrib(attribs, index, EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, strategy);
+            flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
+        }
+
+        if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
+        {
+            setEGLattrib(EGL_CONTEXT_MAJOR_VERSION_KHR, wndconfig->glMajor);
+            setEGLattrib(EGL_CONTEXT_MINOR_VERSION_KHR, wndconfig->glMinor);
         }
+
+        if (mask)
+            setEGLattrib(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, mask);
+
+        if (flags)
+            setEGLattrib(EGL_CONTEXT_FLAGS_KHR, flags);
+
+        if (strategy)
+            setEGLattrib(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, strategy);
+
+        setEGLattrib(EGL_NONE, EGL_NONE);
     }
     else
     {
+        int index = 0;
+
         if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
-            setEGLattrib(attribs, index, EGL_CONTEXT_CLIENT_VERSION, wndconfig->glMajor);
-    }
+            setEGLattrib(EGL_CONTEXT_CLIENT_VERSION, wndconfig->glMajor);
 
-    setEGLattrib(attribs, index, EGL_NONE, EGL_NONE);
+        setEGLattrib(EGL_NONE, EGL_NONE);
+    }
 
     window->EGL.context = eglCreateContext(_glfwLibrary.EGL.display,
                                            config, share, attribs);
@@ -341,8 +337,7 @@ static int createContext(_GLFWwindow* window,
     {
         // TODO: Handle all the various error codes here
 
-        _glfwSetError(GLFW_PLATFORM_ERROR,
-                      "EGL: Failed to create context");
+        _glfwSetError(GLFW_PLATFORM_ERROR, "EGL: Failed to create context");
         return GL_FALSE;
     }
 
@@ -499,6 +494,22 @@ void _glfwDestroyContext(_GLFWwindow* window)
 }
 
 
+//========================================================================
+// Analyzes the specified context for possible recreation
+//========================================================================
+
+int _glfwAnalyzeContext(const _GLFWwindow* window,
+                        const _GLFWwndconfig* wndconfig,
+                        const _GLFWfbconfig* fbconfig)
+{
+#if _GLFW_WIN32
+    return _GLFW_RECREATION_NOT_NEEDED;
+#else
+    return 0;
+#endif
+}
+
+
 //========================================================================
 // Make the OpenGL context associated with the specified window current
 //========================================================================

+ 1 - 1
src/egl_platform.h

@@ -36,7 +36,7 @@
 // This path may need to be changed if you build GLFW using your own setup
 // We ship and use our own copy of eglext.h since GLFW uses fairly new
 // extensions and not all operating systems come with an up-to-date version
-#include "../support/GL/eglext.h"
+#include "../support/EGL/eglext.h"
 
 // Do we have support for dlopen/dlsym?
 #if defined(_GLFW_HAS_DLOPEN)

+ 1 - 1
src/gamma.c

@@ -55,7 +55,7 @@ GLFWAPI void glfwSetGamma(float gamma)
     if (gamma <= 0.f)
     {
         _glfwSetError(GLFW_INVALID_VALUE,
-                      "glfwSetGamma: Gamma value must be greater than zero");
+                      "Gamma value must be greater than zero");
         return;
     }
 

+ 78 - 74
src/glx_context.c

@@ -221,7 +221,7 @@ static int errorHandler(Display *display, XErrorEvent* event)
 // Create the actual OpenGL context
 //========================================================================
 
-#define setGLXattrib(attribs, index, attribName, attribValue) \
+#define setGLXattrib(attribName, attribValue) \
     attribs[index++] = attribName; \
     attribs[index++] = attribValue;
 
@@ -230,7 +230,6 @@ static int createContext(_GLFWwindow* window,
                          GLXFBConfigID fbconfigID)
 {
     int attribs[40];
-    int dummy, index;
     GLXFBConfig* fbconfig;
     GLXContext share = NULL;
 
@@ -239,17 +238,18 @@ static int createContext(_GLFWwindow* window,
 
     // Retrieve the previously selected GLXFBConfig
     {
-        index = 0;
+        int dummy, index = 0;
 
-        setGLXattrib(attribs, index, GLX_FBCONFIG_ID, (int) fbconfigID);
-        setGLXattrib(attribs, index, None, None);
+        setGLXattrib(GLX_FBCONFIG_ID, (int) fbconfigID);
+        setGLXattrib(None, None);
 
         if (_glfwLibrary.GLX.SGIX_fbconfig)
         {
-            fbconfig = _glfwLibrary.GLX.ChooseFBConfigSGIX(_glfwLibrary.X11.display,
-                                                           _glfwLibrary.X11.screen,
-                                                           attribs,
-                                                           &dummy);
+            fbconfig =
+                _glfwLibrary.GLX.ChooseFBConfigSGIX(_glfwLibrary.X11.display,
+                                                    _glfwLibrary.X11.screen,
+                                                    attribs,
+                                                    &dummy);
         }
         else
         {
@@ -270,8 +270,9 @@ static int createContext(_GLFWwindow* window,
     // Retrieve the corresponding visual
     if (_glfwLibrary.GLX.SGIX_fbconfig)
     {
-        window->GLX.visual = _glfwLibrary.GLX.GetVisualFromFBConfigSGIX(_glfwLibrary.X11.display,
-                                                                        *fbconfig);
+        window->GLX.visual =
+            _glfwLibrary.GLX.GetVisualFromFBConfigSGIX(_glfwLibrary.X11.display,
+                                                       *fbconfig);
     }
     else
     {
@@ -288,95 +289,98 @@ static int createContext(_GLFWwindow* window,
         return GL_FALSE;
     }
 
-    if (_glfwLibrary.GLX.ARB_create_context)
+    if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
     {
-        index = 0;
-
-        if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
+        if (!_glfwLibrary.GLX.ARB_create_context ||
+            !_glfwLibrary.GLX.ARB_create_context_profile ||
+            !_glfwLibrary.GLX.EXT_create_context_es2_profile)
         {
-            // Request an explicitly versioned context
-
-            setGLXattrib(attribs, index, GLX_CONTEXT_MAJOR_VERSION_ARB, wndconfig->glMajor);
-            setGLXattrib(attribs, index, GLX_CONTEXT_MINOR_VERSION_ARB, wndconfig->glMinor);
+            _glfwSetError(GLFW_VERSION_UNAVAILABLE,
+                          "GLX: OpenGL ES requested but "
+                          "GLX_EXT_create_context_es2_profile is unavailable");
+            return GL_FALSE;
         }
+    }
 
-        if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
+    if (wndconfig->glForward)
+    {
+        if (!_glfwLibrary.GLX.ARB_create_context)
         {
-            if (!_glfwLibrary.GLX.ARB_create_context_profile ||
-                !_glfwLibrary.GLX.EXT_create_context_es2_profile)
-            {
-                _glfwSetError(GLFW_VERSION_UNAVAILABLE,
-                              "GLX: OpenGL ES 2.x requested but "
-                              "GLX_EXT_create_context_es2_profile is unavailable");
-                return GL_FALSE;
-            }
-
-            setGLXattrib(attribs, index,
-                         GLX_CONTEXT_PROFILE_MASK_ARB,
-                         GLX_CONTEXT_ES2_PROFILE_BIT_EXT);
+            _glfwSetError(GLFW_VERSION_UNAVAILABLE,
+                          "GLX: Forward compatibility requested but "
+                          "GLX_ARB_create_context_profile is unavailable");
+            return GL_FALSE;
         }
+    }
 
-        if (wndconfig->glForward || wndconfig->glDebug || wndconfig->glRobustness)
+    if (wndconfig->glProfile)
+    {
+        if (!_glfwLibrary.GLX.ARB_create_context ||
+            !_glfwLibrary.GLX.ARB_create_context_profile)
         {
-            int flags = 0;
+            _glfwSetError(GLFW_VERSION_UNAVAILABLE,
+                          "GLX: An OpenGL profile requested but "
+                          "GLX_ARB_create_context_profile is unavailable");
+            return GL_FALSE;
+        }
+    }
+
+    if (_glfwLibrary.GLX.ARB_create_context)
+    {
+        int index = 0, mask = 0, flags = 0, strategy = 0;
 
+        if (wndconfig->clientAPI == GLFW_OPENGL_API)
+        {
             if (wndconfig->glForward)
                 flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
 
             if (wndconfig->glDebug)
                 flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
 
-            if (wndconfig->glRobustness)
-                flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB;
-
-            setGLXattrib(attribs, index, GLX_CONTEXT_FLAGS_ARB, flags);
+            if (wndconfig->glProfile)
+            {
+                if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
+                    mask |= GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
+                else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
+                    mask |= GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
+            }
         }
+        else
+            mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
 
-        if (wndconfig->glProfile)
+        if (wndconfig->glRobustness != GLFW_NO_ROBUSTNESS)
         {
-            int flags = 0;
-
-            if (!_glfwLibrary.GLX.ARB_create_context_profile)
+            if (_glfwLibrary.GLX.ARB_create_context_robustness)
             {
-                _glfwSetError(GLFW_VERSION_UNAVAILABLE,
-                              "GLX: An OpenGL profile requested but "
-                              "GLX_ARB_create_context_profile is unavailable");
-                return GL_FALSE;
-            }
+                if (wndconfig->glRobustness == GLFW_NO_RESET_NOTIFICATION)
+                    strategy = GLX_NO_RESET_NOTIFICATION_ARB;
+                else if (wndconfig->glRobustness == GLFW_LOSE_CONTEXT_ON_RESET)
+                    strategy = GLX_LOSE_CONTEXT_ON_RESET_ARB;
 
-            if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
-                flags = GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
-            else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
-                flags = GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
-
-            setGLXattrib(attribs, index, GLX_CONTEXT_PROFILE_MASK_ARB, flags);
+                flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB;
+            }
         }
 
-        if (wndconfig->glRobustness)
+        if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
         {
-            int strategy;
+            // NOTE: Only request an explicitly versioned context when
+            // necessary, as explicitly requesting version 1.0 does not always
+            // return the highest available version
 
-            if (!_glfwLibrary.GLX.ARB_create_context_robustness)
-            {
-                _glfwSetError(GLFW_VERSION_UNAVAILABLE,
-                              "GLX: An OpenGL robustness strategy was "
-                              "requested but GLX_ARB_create_context_robustness "
-                              "is unavailable");
-                return GL_FALSE;
-            }
+            setGLXattrib(GLX_CONTEXT_MAJOR_VERSION_ARB, wndconfig->glMajor);
+            setGLXattrib(GLX_CONTEXT_MINOR_VERSION_ARB, wndconfig->glMinor);
+        }
 
-            if (wndconfig->glRobustness == GLFW_NO_RESET_NOTIFICATION)
-                strategy = GLX_NO_RESET_NOTIFICATION_ARB;
-            else if (wndconfig->glRobustness == GLFW_LOSE_CONTEXT_ON_RESET)
-                strategy = GLX_LOSE_CONTEXT_ON_RESET_ARB;
+        if (mask)
+            setGLXattrib(GLX_CONTEXT_PROFILE_MASK_ARB, mask);
 
-            setGLXattrib(attribs,
-                         index,
-                         GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
-                         strategy);
-        }
+        if (flags)
+            setGLXattrib(GLX_CONTEXT_FLAGS_ARB, flags);
+
+        if (strategy)
+            setGLXattrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, strategy);
 
-        setGLXattrib(attribs, index, None, None);
+        setGLXattrib(None, None);
 
         // This is the only place we set an Xlib error handler, and we only do
         // it because glXCreateContextAttribsARB generates a BadMatch error if
@@ -422,7 +426,7 @@ static int createContext(_GLFWwindow* window,
         // TODO: Handle all the various error codes here
 
         _glfwSetError(GLFW_PLATFORM_ERROR,
-                      "GLX: Failed to create OpenGL context");
+                      "GLX: Failed to create context");
         return GL_FALSE;
     }
 

+ 2 - 2
src/input.c

@@ -323,7 +323,7 @@ GLFWAPI int glfwGetKey(GLFWwindow handle, int key)
     if (key < 0 || key > GLFW_KEY_LAST)
     {
         _glfwSetError(GLFW_INVALID_ENUM,
-                      "glfwGetKey: The specified key is invalid");
+                      "The specified key is invalid");
         return GLFW_RELEASE;
     }
 
@@ -355,7 +355,7 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow handle, int button)
     if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
     {
         _glfwSetError(GLFW_INVALID_ENUM,
-                      "glfwGetMouseButton: The specified mouse button is invalid");
+                      "The specified mouse button is invalid");
         return GLFW_RELEASE;
     }
 

+ 1 - 1
src/nsgl_context.m

@@ -51,7 +51,7 @@ int _glfwInitOpenGL(void)
     if (pthread_key_create(&_glfwCurrentTLS, NULL) != 0)
     {
         _glfwSetError(GLFW_PLATFORM_ERROR,
-                      "Cocoa/NSGL: Failed to create context TLS");
+                      "NSOpenGL: Failed to create context TLS");
         return GL_FALSE;
     }
 

+ 122 - 69
src/wgl_context.c

@@ -329,12 +329,16 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
 // Creates an OpenGL context on the specified device context
 //========================================================================
 
+#define setWGLattrib(attribName, attribValue) \
+    attribs[index++] = attribName; \
+    attribs[index++] = attribValue;
+
 static GLboolean createContext(_GLFWwindow* window,
                                const _GLFWwndconfig* wndconfig,
                                int pixelFormat)
 {
+    int attribs[40];
     PIXELFORMATDESCRIPTOR pfd;
-    int i = 0, attribs[40];
     HGLRC share = NULL;
 
     if (wndconfig->share)
@@ -356,94 +360,56 @@ static GLboolean createContext(_GLFWwindow* window,
 
     if (window->WGL.ARB_create_context)
     {
-        // Use the newer wglCreateContextAttribsARB creation method
-
-        if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
-        {
-            // Request an explicitly versioned context
-
-            attribs[i++] = WGL_CONTEXT_MAJOR_VERSION_ARB;
-            attribs[i++] = wndconfig->glMajor;
-            attribs[i++] = WGL_CONTEXT_MINOR_VERSION_ARB;
-            attribs[i++] = wndconfig->glMinor;
-        }
+        int index = 0, mask = 0, flags = 0, strategy = 0;
 
-        if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
+        if (wndconfig->clientAPI == GLFW_OPENGL_API)
         {
-            if (!window->WGL.ARB_create_context_profile ||
-                !window->WGL.EXT_create_context_es2_profile)
-            {
-                _glfwSetError(GLFW_VERSION_UNAVAILABLE,
-                            "Win32/WGL: OpenGL ES 2.x requested but "
-                            "WGL_EXT_create_context_es2_profile is unavailable");
-                return GL_FALSE;
-            }
-
-            attribs[i++] = WGL_CONTEXT_PROFILE_MASK_ARB;
-            attribs[i++] = WGL_CONTEXT_ES2_PROFILE_BIT_EXT;
-        }
-
-        if (wndconfig->glForward || wndconfig->glDebug || wndconfig->glRobustness)
-        {
-            int flags = 0;
-
             if (wndconfig->glForward)
                 flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
 
             if (wndconfig->glDebug)
                 flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
 
-            if (wndconfig->glRobustness)
-                flags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB;
-
-            attribs[i++] = WGL_CONTEXT_FLAGS_ARB;
-            attribs[i++] = flags;
+            if (wndconfig->glProfile)
+            {
+                if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
+                    mask |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
+                else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
+                    mask |= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
+            }
         }
+        else
+            mask |= WGL_CONTEXT_ES2_PROFILE_BIT_EXT;
 
-        if (wndconfig->glProfile)
+        if (wndconfig->glRobustness)
         {
-            int flags = 0;
-
-            if (!window->WGL.ARB_create_context_profile)
+            if (window->WGL.ARB_create_context_robustness)
             {
-                _glfwSetError(GLFW_VERSION_UNAVAILABLE,
-                              "WGL: OpenGL profile requested but "
-                              "WGL_ARB_create_context_profile is unavailable");
-                return GL_FALSE;
-            }
+                if (wndconfig->glRobustness == GLFW_NO_RESET_NOTIFICATION)
+                    strategy = WGL_NO_RESET_NOTIFICATION_ARB;
+                else if (wndconfig->glRobustness == GLFW_LOSE_CONTEXT_ON_RESET)
+                    strategy = WGL_LOSE_CONTEXT_ON_RESET_ARB;
 
-            if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
-                flags = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
-            else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
-                flags = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
-
-            attribs[i++] = WGL_CONTEXT_PROFILE_MASK_ARB;
-            attribs[i++] = flags;
+                flags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB;
+            }
         }
 
-        if (wndconfig->glRobustness)
+        if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
         {
-            int strategy = 0;
+            setWGLattrib(WGL_CONTEXT_MAJOR_VERSION_ARB, wndconfig->glMajor);
+            setWGLattrib(WGL_CONTEXT_MINOR_VERSION_ARB, wndconfig->glMinor);
+        }
 
-            if (!window->WGL.ARB_create_context_robustness)
-            {
-                _glfwSetError(GLFW_VERSION_UNAVAILABLE,
-                              "WGL: An OpenGL robustness strategy was "
-                              "requested but WGL_ARB_create_context_robustness "
-                              "is unavailable");
-                return GL_FALSE;
-            }
+        if (flags)
+            setWGLattrib(WGL_CONTEXT_FLAGS_ARB, flags);
 
-            if (wndconfig->glRobustness == GLFW_NO_RESET_NOTIFICATION)
-                strategy = WGL_NO_RESET_NOTIFICATION_ARB;
-            else if (wndconfig->glRobustness == GLFW_LOSE_CONTEXT_ON_RESET)
-                strategy = WGL_LOSE_CONTEXT_ON_RESET_ARB;
+        if (mask)
+            setWGLattrib(WGL_CONTEXT_PROFILE_MASK_ARB, mask);
 
-            attribs[i++] = WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB;
-            attribs[i++] = strategy;
-        }
+        if (strategy)
+            setWGLattrib(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, strategy);
 
-        attribs[i++] = 0;
+        setWGLattrib(0, 0);
 
         window->WGL.context = window->WGL.CreateContextAttribsARB(window->WGL.DC,
                                                                   share,
@@ -483,6 +449,8 @@ static GLboolean createContext(_GLFWwindow* window,
     return GL_TRUE;
 }
 
+#undef setWGLattrib
+
 
 //////////////////////////////////////////////////////////////////////////
 //////                       GLFW internal API                      //////
@@ -554,6 +522,91 @@ void _glfwDestroyContext(_GLFWwindow* window)
 }
 
 
+//========================================================================
+// Analyzes the specified context for possible recreation
+//========================================================================
+
+int _glfwAnalyzeContext(const _GLFWwindow* window,
+                        const _GLFWwndconfig* wndconfig,
+                        const _GLFWfbconfig* fbconfig)
+{
+    GLboolean required = GL_FALSE;
+
+    if (wndconfig->clientAPI == GLFW_OPENGL_API)
+    {
+        if (wndconfig->glForward)
+        {
+            if (!window->WGL.ARB_create_context)
+            {
+                _glfwSetError(GLFW_VERSION_UNAVAILABLE,
+                              "WGL: A forward compatible OpenGL context "
+                              "requested but WGL_ARB_create_context is "
+                              "unavailable");
+                return _GLFW_RECREATION_IMPOSSIBLE;
+            }
+
+            required = GL_TRUE;
+        }
+
+        if (wndconfig->glProfile)
+        {
+            if (!window->WGL.ARB_create_context_profile)
+            {
+                _glfwSetError(GLFW_VERSION_UNAVAILABLE,
+                              "WGL: OpenGL profile requested but "
+                              "WGL_ARB_create_context_profile is unavailable");
+                return _GLFW_RECREATION_IMPOSSIBLE;
+            }
+
+            required = GL_TRUE;
+        }
+    }
+    else
+    {
+        if (!window->WGL.ARB_create_context ||
+            !window->WGL.ARB_create_context_profile ||
+            !window->WGL.EXT_create_context_es2_profile)
+        {
+            _glfwSetError(GLFW_VERSION_UNAVAILABLE,
+                          "WGL: OpenGL ES requested but "
+                          "WGL_ARB_create_context_es2_profile is unavailable");
+            return _GLFW_RECREATION_IMPOSSIBLE;
+        }
+
+        required = GL_TRUE;
+    }
+
+    if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
+    {
+        if (window->WGL.ARB_create_context)
+            required = GL_TRUE;
+    }
+
+    if (wndconfig->glDebug)
+    {
+        if (window->WGL.ARB_create_context)
+            required = GL_TRUE;
+    }
+
+    if (fbconfig->samples > 0)
+    {
+        // We want FSAA, but can we get it?
+        // FSAA is not a hard constraint, so otherwise we just don't care
+
+        if (window->WGL.ARB_multisample && window->WGL.ARB_pixel_format)
+        {
+            // We appear to have both the extension and the means to ask for it
+            required = GL_TRUE;
+        }
+    }
+
+    if (required)
+        return _GLFW_RECREATION_REQUIRED;
+
+    return _GLFW_RECREATION_NOT_NEEDED;
+}
+
+
 //////////////////////////////////////////////////////////////////////////
 //////                       GLFW platform API                      //////
 //////////////////////////////////////////////////////////////////////////

+ 7 - 0
src/win32_platform.h

@@ -105,6 +105,10 @@ typedef DWORD (WINAPI * TIMEGETTIME_T) (void);
 // between applications using different versions of GLFW
 #define _GLFW_WNDCLASSNAME L"GLFW30"
 
+#define _GLFW_RECREATION_NOT_NEEDED 0
+#define _GLFW_RECREATION_REQUIRED   1
+#define _GLFW_RECREATION_IMPOSSIBLE 2
+
 
 #if defined(_GLFW_WGL)
  #include "wgl_platform.h"
@@ -218,6 +222,9 @@ int _glfwCreateContext(_GLFWwindow* window,
                        const _GLFWwndconfig* wndconfig,
                        const _GLFWfbconfig* fbconfig);
 void _glfwDestroyContext(_GLFWwindow* window);
+int _glfwAnalyzeContext(const _GLFWwindow* window,
+                        const _GLFWwndconfig* wndconfig,
+                        const _GLFWfbconfig* fbconfig);
 
 // Fullscreen support
 void _glfwSetVideoMode(int* width, int* height,

+ 5 - 50
src/win32_window.c

@@ -866,7 +866,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
                               const _GLFWwndconfig* wndconfig,
                               const _GLFWfbconfig* fbconfig)
 {
-    GLboolean recreateContext = GL_FALSE;
+    int status;
 
     window->Win32.desiredRefreshRate = wndconfig->refreshRate;
 
@@ -900,57 +900,12 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
     if (!createWindow(window, wndconfig, fbconfig))
         return GL_FALSE;
 
-    if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
-    {
-        if (window->WGL.ARB_create_context)
-            recreateContext = GL_TRUE;
-    }
+    status = _glfwAnalyzeContext(window, wndconfig, fbconfig);
 
-    if (wndconfig->glDebug)
-    {
-        if (window->WGL.ARB_create_context)
-            recreateContext = GL_TRUE;
-    }
-
-    if (wndconfig->glForward)
-    {
-        if (!window->WGL.ARB_create_context)
-        {
-            _glfwSetError(GLFW_VERSION_UNAVAILABLE,
-                          "WGL: A forward compatible OpenGL context requested "
-                          "but WGL_ARB_create_context is unavailable");
-            return GL_FALSE;
-        }
-
-        recreateContext = GL_TRUE;
-    }
-
-    if (wndconfig->glProfile)
-    {
-        if (!window->WGL.ARB_create_context_profile)
-        {
-            _glfwSetError(GLFW_VERSION_UNAVAILABLE,
-                          "WGL: OpenGL profile requested but "
-                          "WGL_ARB_create_context_profile is unavailable");
-            return GL_FALSE;
-        }
-
-        recreateContext = GL_TRUE;
-    }
-
-    if (fbconfig->samples > 0)
-    {
-        // We want FSAA, but can we get it?
-        // FSAA is not a hard constraint, so otherwise we just don't care
-
-        if (window->WGL.ARB_multisample && window->WGL.ARB_pixel_format)
-        {
-            // We appear to have both the FSAA extension and the means to ask for it
-            recreateContext = GL_TRUE;
-        }
-    }
+    if (status == _GLFW_RECREATION_IMPOSSIBLE)
+        return GL_FALSE;
 
-    if (recreateContext)
+    if (status == _GLFW_RECREATION_REQUIRED)
     {
         // Some window hints require us to re-create the context using WGL
         // extensions retrieved through the current context, as we cannot check

+ 2 - 3
src/window.c

@@ -253,7 +253,7 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
     wndconfig.glForward      = _glfwLibrary.hints.glForward ? GL_TRUE : GL_FALSE;
     wndconfig.glDebug        = _glfwLibrary.hints.glDebug ? GL_TRUE : GL_FALSE;
     wndconfig.glProfile      = _glfwLibrary.hints.glProfile;
-    wndconfig.glRobustness   = _glfwLibrary.hints.glRobustness ? GL_TRUE : GL_FALSE;
+    wndconfig.glRobustness   = _glfwLibrary.hints.glRobustness;
     wndconfig.monitor        = (_GLFWmonitor*) monitor;
     wndconfig.share          = (_GLFWwindow*) share;
 
@@ -266,8 +266,7 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
 
     if (width <= 0 || height <= 0)
     {
-        _glfwSetError(GLFW_INVALID_VALUE,
-                      "glfwCreateWindow: Invalid window size");
+        _glfwSetError(GLFW_INVALID_VALUE, "Invalid window size");
         return GL_FALSE;
     }
 

+ 0 - 0
support/GL/eglext.h → support/EGL/eglext.h


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 936 - 38
support/GL/glext.h


+ 21 - 5
support/GL/glxext.h

@@ -6,7 +6,7 @@ extern "C" {
 #endif
 
 /*
-** Copyright (c) 2007-2010 The Khronos Group Inc.
+** Copyright (c) 2007-2012 The Khronos Group Inc.
 ** 
 ** Permission is hereby granted, free of charge, to any person obtaining a
 ** copy of this software and/or associated documentation files (the
@@ -48,9 +48,9 @@ extern "C" {
 /*************************************************************/
 
 /* Header file version number, required by OpenGL ABI for Linux */
-/* glxext.h last updated 2010/08/06 */
+/* glxext.h last updated 2012/02/29 */
 /* Current version at http://www.opengl.org/registry/ */
-#define GLX_GLXEXT_VERSION 32
+#define GLX_GLXEXT_VERSION 33
 
 #ifndef GLX_VERSION_1_3
 #define GLX_WINDOW_BIT                     0x00000001
@@ -440,6 +440,14 @@ extern "C" {
 #define GLX_CONTEXT_ES2_PROFILE_BIT_EXT    0x00000004
 #endif
 
+#ifndef GLX_EXT_swap_control_tear
+#define GLX_LATE_SWAPS_TEAR_EXT            0x20F3
+#endif
+
+#ifndef GLX_EXT_buffer_age
+#define GLX_BACK_BUFFER_AGE_EXT            0x20F4
+#endif
+
 
 /*************************************************************/
 
@@ -964,9 +972,9 @@ typedef void ( * PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoC
 #ifndef GLX_EXT_swap_control
 #define GLX_EXT_swap_control 1
 #ifdef GLX_GLXEXT_PROTOTYPES
-extern int glXSwapIntervalEXT (Display *dpy, GLXDrawable drawable, int interval);
+extern void glXSwapIntervalEXT (Display *dpy, GLXDrawable drawable, int interval);
 #endif /* GLX_GLXEXT_PROTOTYPES */
-typedef int ( * PFNGLXSWAPINTERVALEXTPROC) (Display *dpy, GLXDrawable drawable, int interval);
+typedef void ( * PFNGLXSWAPINTERVALEXTPROC) (Display *dpy, GLXDrawable drawable, int interval);
 #endif
 
 #ifndef GLX_NV_copy_image
@@ -985,6 +993,14 @@ typedef void ( * PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx,
 #define GLX_NV_multisample_coverage 1
 #endif
 
+#ifndef GLX_EXT_swap_control_tear
+#define GLX_EXT_swap_control_tear 1
+#endif
+
+#ifndef GLX_EXT_buffer_age
+#define GLX_EXT_buffer_age 1
+#endif
+
 
 #ifdef __cplusplus
 }

+ 45 - 3
support/GL/wglext.h

@@ -6,7 +6,7 @@ extern "C" {
 #endif
 
 /*
-** Copyright (c) 2007-2010 The Khronos Group Inc.
+** Copyright (c) 2007-2012 The Khronos Group Inc.
 ** 
 ** Permission is hereby granted, free of charge, to any person obtaining a
 ** copy of this software and/or associated documentation files (the
@@ -48,9 +48,9 @@ extern "C" {
 /*************************************************************/
 
 /* Header file version number */
-/* wglext.h last updated 2010/08/06 */
+/* wglext.h last updated 2012/01/04 */
 /* Current version at http://www.opengl.org/registry/ */
-#define WGL_WGLEXT_VERSION 22
+#define WGL_WGLEXT_VERSION 24
 
 #ifndef WGL_ARB_buffer_region
 #define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001
@@ -416,6 +416,18 @@ extern "C" {
 #define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
 #endif
 
+#ifndef WGL_NV_DX_interop
+#define WGL_ACCESS_READ_ONLY_NV        0x00000000
+#define WGL_ACCESS_READ_WRITE_NV       0x00000001
+#define WGL_ACCESS_WRITE_DISCARD_NV    0x00000002
+#endif
+
+#ifndef WGL_NV_DX_interop2
+#endif
+
+#ifndef WGL_EXT_swap_control_tear
+#endif
+
 
 /*************************************************************/
 
@@ -893,6 +905,36 @@ typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcNa
 #define WGL_NV_multisample_coverage 1
 #endif
 
+#ifndef WGL_NV_DX_interop
+#define WGL_NV_DX_interop 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle);
+extern HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice);
+extern BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice);
+extern HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
+extern BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject);
+extern BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access);
+extern BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);
+extern BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle);
+typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice);
+typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice);
+typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
+typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject);
+typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access);
+typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);
+typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);
+#endif
+
+#ifndef WGL_NV_DX_interop2
+#define WGL_NV_DX_interop2 1
+#endif
+
+#ifndef WGL_EXT_swap_control_tear
+#define WGL_EXT_swap_control_tear 1
+#endif
+
 
 #ifdef __cplusplus
 }

+ 47 - 11
tests/glfwinfo.c

@@ -77,9 +77,9 @@ static const char* get_client_api_name(int api)
 static const char* get_profile_name_gl(GLint mask)
 {
     if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
-        return "compatibility";
+        return PROFILE_NAME_COMPAT;
     if (mask & GL_CONTEXT_CORE_PROFILE_BIT)
-        return "core";
+        return PROFILE_NAME_CORE;
 
     return "unknown";
 }
@@ -87,9 +87,29 @@ static const char* get_profile_name_gl(GLint mask)
 static const char* get_profile_name_glfw(int profile)
 {
     if (profile == GLFW_OPENGL_COMPAT_PROFILE)
-        return "compatibility";
+        return PROFILE_NAME_COMPAT;
     if (profile == GLFW_OPENGL_CORE_PROFILE)
-        return "core";
+        return PROFILE_NAME_CORE;
+
+    return "unknown";
+}
+
+static const char* get_strategy_name_gl(GLint strategy)
+{
+    if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
+        return STRATEGY_NAME_LOSE;
+    if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
+        return STRATEGY_NAME_NONE;
+
+    return "unknown";
+}
+
+static const char* get_strategy_name_glfw(int strategy)
+{
+    if (strategy == GLFW_LOSE_CONTEXT_ON_RESET)
+        return STRATEGY_NAME_LOSE;
+    if (strategy == GLFW_NO_RESET_NOTIFICATION)
+        return STRATEGY_NAME_NONE;
 
     return "unknown";
 }
@@ -265,9 +285,6 @@ int main(int argc, char** argv)
 
     glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
 
-    // We assume here that we stand a better chance of success by leaving all
-    // possible details of pixel format selection to GLFW
-
     window = glfwCreateWindow(200, 200, "Version", NULL, NULL);
     if (!window)
     {
@@ -303,8 +320,10 @@ int main(int argc, char** argv)
 
             if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
                 printf(" forward-compatible");
-            if (flags & 0)
+            if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
                 printf(" debug");
+            if (flags & GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB)
+                printf(" robustness");
             putchar('\n');
 
             printf("%s context flags parsed by GLFW:", get_client_api_name(api));
@@ -313,6 +332,8 @@ int main(int argc, char** argv)
                 printf(" forward-compatible");
             if (glfwGetWindowParam(window, GLFW_OPENGL_DEBUG_CONTEXT))
                 printf(" debug");
+            if (glfwGetWindowParam(window, GLFW_CONTEXT_ROBUSTNESS) != GLFW_NO_ROBUSTNESS)
+                printf(" robustness");
             putchar('\n');
         }
 
@@ -330,6 +351,24 @@ int main(int argc, char** argv)
                    get_client_api_name(api),
                    get_profile_name_glfw(profile));
         }
+
+        if (glfwExtensionSupported("GL_ARB_robustness"))
+        {
+            int robustness;
+            GLint strategy;
+            glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
+
+            printf("%s robustness strategy (0x%08x): %s\n",
+                   get_client_api_name(api),
+                   strategy,
+                   get_strategy_name_gl(strategy));
+
+            robustness = glfwGetWindowParam(window, GLFW_CONTEXT_ROBUSTNESS);
+
+            printf("%s robustness strategy parsed by GLFW: %s\n",
+                   get_client_api_name(api),
+                   get_strategy_name_glfw(robustness));
+        }
     }
 
     printf("%s context renderer string: \"%s\"\n",
@@ -339,9 +378,6 @@ int main(int argc, char** argv)
            get_client_api_name(api),
            glGetString(GL_VENDOR));
 
-    printf("OpenGL context debug flag saved by GLFW: %s\n",
-           glfwGetWindowParam(window, GLFW_OPENGL_DEBUG_CONTEXT) ? "true" : "false");
-
     if (major > 1)
     {
         printf("%s context shading language version: \"%s\"\n",

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác