mirror of
https://github.com/glfw/glfw.git
synced 2026-09-22 00:49:48 +00:00
Add GLFW_NO_API for creating context-less windows
This commit is contained in:
+29
-17
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user