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.
This commit is contained in:
Camilla Berglund
2012-12-30 01:42:14 +01:00
parent 9af61d06cf
commit 9cc8fc0d0a
23 changed files with 169 additions and 187 deletions

View File

@@ -48,6 +48,11 @@ static void set_swap_interval(GLFWwindow window, int interval)
glfwSetWindowTitle(window, title);
}
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void window_size_callback(GLFWwindow window, int width, int height)
{
glViewport(0, 0, width, height);
@@ -64,17 +69,14 @@ int main(void)
float position;
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_WINDOWED, "", NULL);
if (!window)
{
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
glfwTerminate();
exit(EXIT_FAILURE);
}