This commit is contained in:
Camilla Berglund 2016-03-20 09:39:53 +01:00
parent c1e4c45c7a
commit 5eb2e83c82
3 changed files with 15 additions and 39 deletions

View File

@ -370,6 +370,21 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
return GLFW_FALSE; return GLFW_FALSE;
} }
if (window->context.major < ctxconfig->major ||
(window->context.major == ctxconfig->major &&
window->context.minor < ctxconfig->minor))
{
// The desired OpenGL version is greater than the actual version
// This only happens if the machine lacks {GLX|WGL}_ARB_create_context
// /and/ the user has requested an OpenGL version greater than 1.0
// For API consistency, we emulate the behavior of the
// {GLX|WGL}_ARB_create_context extension and fail here
_glfwInputError(GLFW_VERSION_UNAVAILABLE, NULL);
return GLFW_FALSE;
}
if (window->context.major >= 3) if (window->context.major >= 3)
{ {
// OpenGL 3.0+ uses a different function for extension string retrieval // OpenGL 3.0+ uses a different function for extension string retrieval
@ -490,28 +505,6 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
return GLFW_TRUE; return GLFW_TRUE;
} }
GLFWbool _glfwIsValidContext(const _GLFWctxconfig* ctxconfig)
{
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
if (window->context.major < ctxconfig->major ||
(window->context.major == ctxconfig->major &&
window->context.minor < ctxconfig->minor))
{
// The desired OpenGL version is greater than the actual version
// This only happens if the machine lacks {GLX|WGL}_ARB_create_context
// /and/ the user has requested an OpenGL version greater than 1.0
// For API consistency, we emulate the behavior of the
// {GLX|WGL}_ARB_create_context extension and fail here
_glfwInputError(GLFW_VERSION_UNAVAILABLE, NULL);
return GLFW_FALSE;
}
return GLFW_TRUE;
}
GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions) GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions)
{ {
const char* start = extensions; const char* start = extensions;

View File

@ -1009,15 +1009,6 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig);
*/ */
GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig); GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig);
/*! @brief Checks whether the current context fulfils the specified hard
* constraints.
* @param[in] ctxconfig The desired context attributes.
* @return `GLFW_TRUE` if the context fulfils the hard constraints, or
* `GLFW_FALSE` otherwise.
* @ingroup utility
*/
GLFWbool _glfwIsValidContext(const _GLFWctxconfig* ctxconfig);
/*! @ingroup utility /*! @ingroup utility
*/ */
void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size); void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size);

View File

@ -210,14 +210,6 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
return NULL; return NULL;
} }
// Verify the context against the requested parameters
if (!_glfwIsValidContext(&ctxconfig))
{
glfwDestroyWindow((GLFWwindow*) window);
_glfwPlatformMakeContextCurrent(previous);
return NULL;
}
// Restore the previously current context (or NULL) // Restore the previously current context (or NULL)
_glfwPlatformMakeContextCurrent(previous); _glfwPlatformMakeContextCurrent(previous);
} }