Added GLFW_NO_API check to glfwCreateUserContext and error documentation.

This commit is contained in:
Doug Binks 2020-07-16 15:20:25 +01:00
parent 1d647668af
commit 375fcdeadb
2 changed files with 20 additions and 0 deletions

View File

@ -5834,6 +5834,11 @@ GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
* Contexts share resources with the window context and with any other * Contexts share resources with the window context and with any other
* user context created for that window. * user context created for that window.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED,
* @ref GLFW_INVALID_VALUE the window parameter is `NULL`,
* @ref GLFW_NO_WINDOW_CONTEXT if the window has no OpenGL or
* OpenGL US context, and @ref GLFW_PLATFORM_ERROR.
*
* @param[in] window The Window for which the user context is to be * @param[in] window The Window for which the user context is to be
* created. * created.
* @return The handle of the user context created, or `NULL` if an * @return The handle of the user context created, or `NULL` if an

View File

@ -767,6 +767,21 @@ GLFWAPI GLFWusercontext* glfwCreateUserContext(GLFWwindow* handle)
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (!window)
{
_glfwInputError(GLFW_INVALID_VALUE,
"Cannot create a user context without a valid window handle");
return NULL;
}
if (window->context.client == GLFW_NO_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT,
"Cannot create a user context for a window that has no OpenGL or OpenGL ES context");
return NULL;
}
context = _glfwPlatformCreateUserContext(window); context = _glfwPlatformCreateUserContext(window);
return (GLFWusercontext*)context; return (GLFWusercontext*)context;