@ -36,7 +36,7 @@
//========================================================================
// Parses the OpenGL version string and extracts the version number
// Parses the client API version string and extracts the version number
//========================================================================
static void parseGLVersion ( int * major , int * minor , int * rev )
@ -256,89 +256,125 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
//========================================================================
// Checks whether the OpenGL part of the window config is sane
// 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 )
{
if ( wndconfig - > glMajor < 1 | | wndconfig - > glMinor < 0 )
if ( wndconfig - > clientAPI ! = GLFW_OPENGL_API & &
wndconfig - > clientAPI ! = GLFW_OPENGL_ES_API )
{
// OpenGL 1.0 is the smallest valid version
_glfwSetError ( GLFW_INVALID_VALUE ,
" glfwOpenWindow: 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 ,
" glfwOpenWindow: Invalid OpenGL version requested " ) ;
_glfwSetError ( GLFW_INVALID_ENUM ,
" glfwOpenWindow: Invalid client API 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 ,
" glfwOpenWindow: 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 ,
" glfwOpenWindow: Invalid OpenGL version requested " ) ;
return GL_FALSE ;
}
else
{
// For now, let everything else through
}
if ( wndconfig - > glProfile = = GLFW_OPENGL_ES2_PROFILE )
if ( wndconfig - > clientAPI = = GLFW_OPENGL_API )
{
if ( wndconfig - > glMajor ! = 2 | | wndconfig - > glMinor < 0 )
if ( wndconfig - > glMajor < 1 | | wndconfig - > glMinor < 0 )
{
// OpenGL 1.0 is the smallest valid version
_glfwSetError ( GLFW_INVALID_VALUE ,
" glfwOpenWindow: 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 ,
" glfwOpenWindow: 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 ,
" glfwOpenWindow: 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 ,
" glfwOpenWindow: Invalid OpenGL version requested " ) ;
return GL_FALSE ;
}
else
{
// For now, let everything else through
}
if ( wndconfig - > glProfile )
{
// The OpenGL ES 2.0 profile is currently only defined for version
// 2.0 (see {WGL|GLX}_EXT_create_context_es2_profile), but for
// compatibility with future updates to OpenGL ES, we allow
// everything 2.x and let the driver report invalid 2.x versions
if ( wndconfig - > glProfile ! = GLFW_OPENGL_CORE_PROFILE & &
wndconfig - > glProfile ! = GLFW_OPENGL_COMPAT_PROFILE )
{
_glfwSetError ( GLFW_INVALID_ENUM ,
" glfwOpenWindow: Invalid OpenGL profile requested " ) ;
return GL_FALSE ;
}
if ( wndconfig - > glMajor < 3 | |
( wndconfig - > glMajor = = 3 & & wndconfig - > glMinor < 2 ) )
{
// Desktop OpenGL context profiles are only defined for version 3.2
// and above
_glfwSetError ( GLFW_INVALID_VALUE ,
" glfwOpenWindow: Context profiles only exist for "
" OpenGL version 3.2 and above " ) ;
return GL_FALSE ;
}
}
if ( wndconfig - > glForward & & wndconfig - > glMajor < 3 )
{
// Forward-compatible contexts are only defined for OpenGL version 3.0 and above
_glfwSetError ( GLFW_INVALID_VALUE ,
" glfwOpenWindow: Invalid OpenGL ES 2.x version requested " ) ;
" glfwOpenWindow: Forward compatibility only exist for "
" OpenGL version 3.0 and above " ) ;
return GL_FALSE ;
}
}
else if ( wndconfig - > glProfile )
else if ( wndconfig - > clientAPI = = GLFW_OPENGL_ES_API )
{
if ( wndconfig - > glProfile ! = GLFW_OPENGL_CORE_PROFILE & &
wndconfig - > glProfile ! = GLFW_OPENGL_COMPAT_PROFILE )
if ( wndconfig - > glMajor < 1 | | wndconfig - > glMinor < 0 )
{
_glfwSetError ( GLFW_INVALID_ENUM ,
" glfwOpenWindow: Invalid OpenGL profile requested " ) ;
// OpenGL ES 1.0 is the smallest valid version
_glfwSetError ( GLFW_INVALID_VALUE ,
" glfwOpenWindow: Invalid OpenGL ES version requested " ) ;
return GL_FALSE ;
}
if ( wndconfig - > glMajor < 3 | |
( wndconfig - > glMajor = = 3 & & wndconfig - > glMinor < 2 ) )
if ( wndconfig - > glMajor = = 1 & & wndconfig - > glMinor > 1 )
{
// Desktop OpenGL context profiles are only defined for version 3.2
// and above
// OpenGL ES 1.x series ended with version 1.1
_glfwSetError ( GLFW_INVALID_VALUE ,
" glfwOpenWindow: Invalid OpenGL ES version requested " ) ;
return GL_FALSE ;
}
else
{
// For now, let everything else through
}
if ( wndconfig - > glProfile )
{
// OpenGL ES does not support profiles
_glfwSetError ( GLFW_INVALID_VALUE ,
" glfwOpenWindow: Context profiles only exist for "
" OpenGL version 3.2 and above " ) ;
" glfwOpenWindow: Context profiles are not supported "
" by OpenGL ES " ) ;
return GL_FALSE ;
}
}
if ( wndconfig - > glForward & & wndconfig - > glMajor < 3 )
{
// Forward-compatible contexts are only defined for OpenGL version 3.0 and above
_glfwSetError ( GLFW_INVALID_VALUE ,
" glfwOpenWindow: Forward compatibility only exist for "
" OpenGL version 3.0 and above " ) ;
return GL_FALSE ;
if ( wndconfig - > glForward )
{
// OpenGL ES does not support Forward-compatibility
_glfwSetError ( GLFW_INVALID_VALUE ,
" glfwOpenWindow: Forward compatibility is not "
" supported by OpenGL ES " ) ;
return GL_FALSE ;
}
}
if ( wndconfig - > glRobustness )
@ -347,7 +383,8 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
wndconfig - > glRobustness ! = GLFW_OPENGL_LOSE_CONTEXT_ON_RESET )
{
_glfwSetError ( GLFW_INVALID_VALUE ,
" glfwOpenWindow: Invalid OpenGL robustness mode requested " ) ;
" glfwOpenWindow: Invalid OpenGL robustness mode "
" requested " ) ;
return GL_FALSE ;
}
}
@ -363,6 +400,8 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
GLboolean _glfwIsValidContext ( _GLFWwindow * window , _GLFWwndconfig * wndconfig )
{
window - > clientAPI = wndconfig - > clientAPI ;
parseGLVersion ( & window - > glMajor , & window - > glMinor , & window - > glRevision ) ;
// Read back forward-compatibility flag
@ -433,7 +472,7 @@ GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig)
//========================================================================
// Check if a string can be found in an OpenGL extension string
// Check if a string can be found in a client API extension string
//========================================================================
int _glfwStringInExtensionString ( const char * string ,
@ -472,7 +511,7 @@ int _glfwStringInExtensionString(const char* string,
//////////////////////////////////////////////////////////////////////////
//========================================================================
// Make the OpenGL context associated with the specified window current
// Make the context associated with the specified window current
//========================================================================
GLFWAPI void glfwMakeContextCurrent ( GLFWwindow handle )
@ -494,7 +533,7 @@ GLFWAPI void glfwMakeContextCurrent(GLFWwindow handle)
//========================================================================
// Returns the window whose OpenGL context is current
// Returns the window whose context is current
//========================================================================
GLFWAPI GLFWwindow glfwGetCurrentContext ( void )
@ -554,7 +593,7 @@ GLFWAPI void glfwSwapInterval(int interval)
//========================================================================
// Check if an OpenGL extension is available at runtime
// Check if a client API extension is available at runtime
//========================================================================
GLFWAPI int glfwExtensionSupported ( const char * extension )
@ -619,8 +658,8 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
//========================================================================
// Get the function pointer to an OpenGL function.
// This function can be used to get access to extended OpenGL functions.
// Get the function pointer to a client API function
// This can be used to get access to client API extension functions
//========================================================================
GLFWAPI GLFWglproc glfwGetProcAddress ( const char * procname )
@ -642,7 +681,7 @@ GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname)
//========================================================================
// Copies the specified OpenGL state categories from src to dst
// Copies the specified context state categories from src to dst
//========================================================================
GLFWAPI void glfwCopyContext ( GLFWwindow hsrc , GLFWwindow hdst , unsigned long mask )