Add GLFW_NO_API for creating context-less windows

This commit is contained in:
Camilla Berglund
2015-06-18 14:03:02 +02:00
parent 0fda5b7b80
commit 496f559c9a
17 changed files with 285 additions and 191 deletions
+29 -17
View File
@@ -142,6 +142,15 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
wndconfig.monitor = (_GLFWmonitor*) monitor;
ctxconfig.share = (_GLFWwindow*) share;
if (ctxconfig.share)
{
if (ctxconfig.share->context.api == GLFW_NO_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
return NULL;
}
}
if (wndconfig.monitor)
{
wndconfig.resizable = GLFW_TRUE;
@@ -181,26 +190,29 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
return NULL;
}
_glfwPlatformMakeContextCurrent(window);
// Retrieve the actual (as opposed to requested) context attributes
if (!_glfwRefreshContextAttribs(&ctxconfig))
if (ctxconfig.api != GLFW_NO_API)
{
glfwDestroyWindow((GLFWwindow*) window);
_glfwPlatformMakeContextCurrent(previous);
return NULL;
}
_glfwPlatformMakeContextCurrent(window);
// Verify the context against the requested parameters
if (!_glfwIsValidContext(&ctxconfig))
{
glfwDestroyWindow((GLFWwindow*) window);
_glfwPlatformMakeContextCurrent(previous);
return NULL;
}
// Retrieve the actual (as opposed to requested) context attributes
if (!_glfwRefreshContextAttribs(&ctxconfig))
{
glfwDestroyWindow((GLFWwindow*) window);
_glfwPlatformMakeContextCurrent(previous);
return NULL;
}
// Restore the previously current context (or NULL)
_glfwPlatformMakeContextCurrent(previous);
// Verify the context against the requested parameters
if (!_glfwIsValidContext(&ctxconfig))
{
glfwDestroyWindow((GLFWwindow*) window);
_glfwPlatformMakeContextCurrent(previous);
return NULL;
}
// Restore the previously current context (or NULL)
_glfwPlatformMakeContextCurrent(previous);
}
if (wndconfig.monitor)
{