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

@@ -54,6 +54,11 @@ static const char* get_mode_name(int mode)
}
}
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);
@@ -85,19 +90,13 @@ static GLboolean open_window(int width, int height, int mode)
double base;
if (!glfwInit())
{
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
return GL_FALSE;
}
base = glfwGetTime();
window_handle = glfwCreateWindow(width, height, mode, "Window Re-opener", NULL);
if (!window_handle)
{
fprintf(stderr, "Failed to open %s mode GLFW window: %s\n", get_mode_name(mode), glfwErrorString(glfwGetError()));
return GL_FALSE;
}
glfwMakeContextCurrent(window_handle);
glfwSwapInterval(1);
@@ -129,6 +128,8 @@ int main(int argc, char** argv)
{
int count = 0;
glfwSetErrorCallback(error_callback);
for (;;)
{
if (!open_window(640, 480, (count & 1) ? GLFW_FULLSCREEN : GLFW_WINDOWED))