mirror of
https://github.com/glfw/glfw.git
synced 2025-04-12 03:42:01 +00:00
Closes #2071, implementing glfwGetErrorDescription
This commit is contained in:
parent
955fbd9d26
commit
7a8a959ea8
@ -2364,6 +2364,29 @@ GLFWAPI const char* glfwGetVersionString(void);
|
||||
*/
|
||||
GLFWAPI int glfwGetError(const char** description);
|
||||
|
||||
/*! @brief Returns the description for a specific error code.
|
||||
*
|
||||
* @param[in] code The error code whose description is requested.
|
||||
* @return The error description pointer belonging to specified error code, or NULL if error code is not found.
|
||||
*
|
||||
* @errors None.
|
||||
*
|
||||
* @pointer_lifetime The returned string is allocated and freed by GLFW. You
|
||||
* should not free it yourself. It is guaranteed to be valid only until the library is terminated.
|
||||
*
|
||||
* @remark This function may be called before @ref glfwInit.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread.
|
||||
*
|
||||
* @sa @ref error_handling
|
||||
* @sa @ref glfwGetError
|
||||
*
|
||||
* @since Added in version 3.3.7.
|
||||
*
|
||||
* @ingroup init
|
||||
*/
|
||||
GLFWAPI const char* glfwGetErrorDescription(int code);
|
||||
|
||||
/*! @brief Sets the error callback.
|
||||
*
|
||||
* This function sets the error callback, which is called with an error code
|
||||
|
17
src/init.c
17
src/init.c
@ -484,6 +484,23 @@ GLFWAPI int glfwGetError(const char** description)
|
||||
return code;
|
||||
}
|
||||
|
||||
GLFWAPI const char* glfwGetErrorDescription(int code)
|
||||
{
|
||||
_GLFWerror* error;
|
||||
|
||||
error = _glfw.errorListHead;
|
||||
|
||||
while (error)
|
||||
{
|
||||
if (error->code == code)
|
||||
return error->description;
|
||||
|
||||
error = error->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
|
||||
{
|
||||
_GLFW_SWAP(GLFWerrorfun, _glfwErrorCallback, cbfun);
|
||||
|
Loading…
Reference in New Issue
Block a user