|
|
|
@ -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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|