From cfb9394c735cea3082f31b7ac8a421405b6843ba Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 27 Jul 2011 18:24:27 +0200 Subject: [PATCH] Copied OS X Lion GL3 support from 2.7.2. --- readme.html | 1 + src/cocoa_window.m | 43 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/readme.html b/readme.html index 481444d0..96a892a2 100644 --- a/readme.html +++ b/readme.html @@ -303,6 +303,7 @@ version of GLFW.

  • Bugfix: The default OpenGL version in the version test was set to 1.1
  • Bugfix: The OpenGL profile and forward-compatibility window parameters were not saved after context creation
  • Bugfix: The FSAA test did not check for the availability of GL_ARB_multisample
  • +
  • [Cocoa] Added support for OpenGL 3.2 core profile in 10.7 Lion and above
  • [Cocoa] Bugfix: The loop condition for saving video modes used the wrong index variable
  • [X11] Added support for the GLX_EXT_swap_control extension as an alternative to GLX_SGI_swap_control
  • [X11] Bugfix: Calling glXCreateContextAttribsARB with an unavailable OpenGL version caused the application to terminate with a BadMatch Xlib error
  • diff --git a/src/cocoa_window.m b/src/cocoa_window.m index df2f708f..c0832805 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -476,15 +476,38 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window, const _GLFWwndconfig *wndconfig, const _GLFWfbconfig *fbconfig) { - // Fail if OpenGL 3.0 or above was requested - if (wndconfig->glMajor > 2) +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 + // Fail if OpenGL 3.3 or above was requested + if( wndconfig->glMajor > 3 || wndconfig->glMajor == 3 && wndconfig->glMinor > 2 ) { _glfwSetError(GLFW_VERSION_UNAVAILABLE, - "Cocoa/NSOpenGL: Mac OS X does not support OpenGL " - "version 3.0 or above"); + "Cocoa/NSOpenGL: The targeted version of Mac OS X does " + "not support OpenGL version 3.3 or above"); return GL_FALSE; } + if( wndconfig->glProfile ) + { + // Fail if a profile other than core was explicitly selected + if( wndconfig->glProfile != GLFW_OPENGL_CORE_PROFILE ) + { + _glfwSetError(GLFW_VERSION_UNAVAILABLE, + "Cocoa/NSOpenGL: The targeted version of Mac OS X " + "only supports the OpenGL core profile"); + return GL_FALSE; + } + } +#else + // Fail if OpenGL 3.0 or above was requested + if( wndconfig->glMajor > 2 ) + { + _glfwSetError(GLFW_VERSION_UNAVAILABLE, + "Cocoa/NSOpenGL: The targeted version of Mac OS X does " + "not support OpenGL version 3.0 or above"); + return GL_FALSE; + } +#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/ + // Fail if a robustness strategy was requested if (wndconfig->glRobustness) { @@ -591,7 +614,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window, unsigned int attribute_count = 0; -#define ADD_ATTR(x) attributes[attribute_count++] = x +#define ADD_ATTR(x) { attributes[attribute_count++] = x; } #define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); } // Arbitrary array size here @@ -607,6 +630,11 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window, CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID())); } +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 + if( wndconfig->glMajor > 2 ) + ADD_ATTR2( NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core ); +#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/ + ADD_ATTR2(NSOpenGLPFAColorSize, colorBits); if (fbconfig->alphaBits > 0) @@ -847,10 +875,9 @@ void _glfwPlatformRefreshWindowParams(void) forVirtualScreen:0]; window->samples = value; - // These are forced to false as long as Mac OS X lacks support for OpenGL 3.0+ - window->glForward = GL_FALSE; + // These this is forced to false as long as Mac OS X lacks support for + // requesting debug contexts window->glDebug = GL_FALSE; - window->glProfile = 0; } //========================================================================