Removed glfwGetError and glfwErrorString. The cached error code cannot be made per-thread unless it required glfwInit (due to lack of __thread on OS X), which would be confusing and partially defeats the purpose of it. Beginners would use the generic error string facility instead of the error callback and then be confused by its nondescript messages. Storing the provided error code from within the error callback, whether globally or per-thread, requires just a few lines of code and hands control to the user without compromising thread safety.
diff --git a/tests/fsfocus.c b/tests/fsfocus.c index a87d136..c83e166 100644 --- a/tests/fsfocus.c +++ b/tests/fsfocus.c
@@ -35,6 +35,11 @@ static GLboolean running = GL_TRUE; +static void error_callback(int error, const char* description) +{ + fprintf(stderr, "Error: %s\n", description); +} + static void window_focus_callback(GLFWwindow window, int focused) { printf("%0.3f: Window %s\n", @@ -76,18 +81,15 @@ { GLFWwindow window; + glfwSetErrorCallback(error_callback); + if (!glfwInit()) - { - fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); exit(EXIT_FAILURE); - } window = glfwCreateWindow(640, 480, GLFW_FULLSCREEN, "Fullscreen focus", NULL); if (!window) { glfwTerminate(); - - fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError())); exit(EXIT_FAILURE); }