diff options
author | Chad Versace <chad.versace@linux.intel.com> | 2012-09-06 08:39:34 -0700 |
---|---|---|
committer | Chad Versace <chad.versace@linux.intel.com> | 2012-09-06 08:40:36 -0700 |
commit | 193993238bfb44740618afd7deb9865f361ce992 (patch) | |
tree | 1f5f40714cb46dd6450e104fb9533d236be22634 /src | |
parent | 5e8420f629446b81db359093095e0a286f41504d (diff) |
glut_waffle: Improve error messages
When a waffle functions fails, print the complete error message returned
emitted by waffle.
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/glut_waffle/glut_waffle.c | 22 | ||||
-rw-r--r-- | src/glut_waffle/priv/common.c | 16 | ||||
-rw-r--r-- | src/glut_waffle/priv/common.h | 3 |
3 files changed, 29 insertions, 12 deletions
diff --git a/src/glut_waffle/glut_waffle.c b/src/glut_waffle/glut_waffle.c index 5837b497e..5496edb0b 100644 --- a/src/glut_waffle/glut_waffle.c +++ b/src/glut_waffle/glut_waffle.c @@ -103,11 +103,11 @@ glutInit(int *argcp, char **argv) waffle_init_attrib_list[1] = _glut->waffle_platform; ok = waffle_init(waffle_init_attrib_list); if (!ok) - glutFatal("waffle_init() failed"); + glutFatalWaffleError("waffle_init"); _glut->display = waffle_display_connect(display_name); if (!_glut->display) - glutFatal("waffle_display_connect() failed"); + glutFatalWaffleError("waffle_display_connect"); } void @@ -173,7 +173,7 @@ glutChooseConfig(void) config = waffle_config_choose(_glut->display, attrib_list); if (!config) - glutFatal("waffle_config_choose() failed"); + glutFatalWaffleError("waffle_config_choose"); return config; } @@ -204,7 +204,7 @@ glutCreateWindow(const char *title) _glut->context = waffle_context_create(config, NULL); if (!_glut->context) - glutFatal("waffle_context_create() failed"); + glutFatalWaffleError("waffle_context_create"); _glut->window = calloc(1, sizeof(*_glut->window)); if (!_glut->window) @@ -214,11 +214,11 @@ glutCreateWindow(const char *title) _glut->window_width, _glut->window_height); if (!_glut->window->waffle) - glutFatal("waffle_window_create() failed"); + glutFatalWaffleError("waffle_window_create"); n_window = waffle_window_get_native(_glut->window->waffle); if (!n_window) - glutFatal("waffle_window_get_window() failed"); + glutFatalWaffleError("waffle_window_get_native"); switch (_glut->waffle_platform) { #ifdef PIGLIT_HAS_X11 @@ -243,7 +243,7 @@ glutCreateWindow(const char *title) ok = waffle_make_current(_glut->display, _glut->window->waffle, _glut->context); if (!ok) - glutFatal("waffle_make_current() failed"); + glutFatalWaffleError("waffle_make_current"); _glut->window->id = ++_glut->window_id_pool; _glut->window->keyboard_cb = _glutDefaultKeyboard; @@ -261,7 +261,7 @@ glutDestroyWindow(int win) ok = waffle_window_destroy(_glut->window->waffle); if (!ok) - glutFatal("waffle_window_destroy() failed"); + glutFatalWaffleError("waffle_window_destroy"); free(_glut->window); _glut->window = NULL; @@ -277,7 +277,7 @@ glutShowWindow(int win) ok = waffle_window_show(_glut->window->waffle); if (!ok) - glutFatal("waffle_window_show() failed"); + glutFatalWaffleError("waffle_window_show"); } void @@ -308,7 +308,7 @@ glutMainLoop(void) ok = waffle_window_show(_glut->window->waffle); if (!ok) - glutFatal("waffle_window_show() failed"); + glutFatalWaffleError("waffle_window_show"); if (_glut->window->reshape_cb) _glut->window->reshape_cb(_glut->window_width, @@ -348,5 +348,5 @@ glutSwapBuffers(void) { bool ok = waffle_window_swap_buffers(_glut->window->waffle); if (!ok) - glutFatal("waffle_window_swap_buffers() failed"); + glutFatalWaffleError("waffle_window_swap_buffers() failed"); } diff --git a/src/glut_waffle/priv/common.c b/src/glut_waffle/priv/common.c index 71e979e63..0020e46f1 100644 --- a/src/glut_waffle/priv/common.c +++ b/src/glut_waffle/priv/common.c @@ -43,10 +43,24 @@ glutFatal(char *format, ...) va_start(args, format); fflush(stdout); - fprintf(stderr, "glut_waffle: "); + fprintf(stderr, "glut_waffle: error: "); vfprintf(stderr, format, args); va_end(args); putc('\n', stderr); exit(1); } + +void +glutFatalWaffleError(const char *waffle_func) +{ + const struct waffle_error_info *info = waffle_error_get_info(); + const char *code = waffle_error_to_string(info->code); + + if (info->message_length > 0) + glutFatal("%s() failed: %s: %s", + waffle_func, code, info->message); + else + glutFatal("%s() failed: %s", + waffle_func, code); +} diff --git a/src/glut_waffle/priv/common.h b/src/glut_waffle/priv/common.h index 1ee28a445..e7775b68d 100644 --- a/src/glut_waffle/priv/common.h +++ b/src/glut_waffle/priv/common.h @@ -76,3 +76,6 @@ extern struct glut_waffle_state *const _glut; void glutFatal(char *format, ...); + +void +glutFatalWaffleError(const char *waffle_func); |