mirror of
https://github.com/glfw/glfw.git
synced 2026-02-17 21:12:34 +01:00
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:
@@ -257,6 +257,16 @@ void calc_grid(void)
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Print errors
|
||||
//========================================================================
|
||||
|
||||
static void error_callback(int error, const char* description)
|
||||
{
|
||||
fprintf(stderr, "Error: %s\n", description);
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Handle key strokes
|
||||
//========================================================================
|
||||
@@ -393,16 +403,15 @@ int main(int argc, char* argv[])
|
||||
double t, dt_total, t_old;
|
||||
int width, height;
|
||||
|
||||
glfwSetErrorCallback(error_callback);
|
||||
|
||||
if (!glfwInit())
|
||||
{
|
||||
fprintf(stderr, "GLFW initialization failed\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
window = glfwCreateWindow(640, 480, GLFW_WINDOWED, "Wave Simulation", NULL);
|
||||
if (!window)
|
||||
{
|
||||
fprintf(stderr, "Could not open window\n");
|
||||
glfwTerminate();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user