Added error callback.

This commit is contained in:
Camilla Berglund
2010-11-23 17:45:23 +01:00
parent 065c77190d
commit f1e7d7c0ea
17 changed files with 154 additions and 132 deletions
+28 -2
View File
@@ -45,9 +45,17 @@ static int _glfwError = GLFW_NO_ERROR;
// Sets the current error value
//========================================================================
void _glfwSetError(int error)
void _glfwSetError(int error, const char* description)
{
_glfwError = error;
if (_glfwLibrary.errorCallback)
{
if (!description)
description = glfwErrorString(error);
_glfwLibrary.errorCallback(error, description);
}
else
_glfwError = error;
}
@@ -99,3 +107,21 @@ GLFWAPI const char* glfwErrorString(int error)
}
}
//========================================================================
// Sets the callback function for GLFW errors
//========================================================================
GLFWAPI void glfwSetErrorCallback(GLFWerrorfun cbfun)
{
if (!_glfwInitialized)
{
// TODO: Uhm... Hmm...
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_glfwLibrary.errorCallback = cbfun;
}