diff options
author | Chad Versace <chad.versace@linux.intel.com> | 2012-10-29 06:18:32 -0700 |
---|---|---|
committer | Chad Versace <chad.versace@linux.intel.com> | 2012-10-29 09:21:04 -0700 |
commit | c6376ef529b6bfa9b023f26676a4e5e3f9b2fd7e (patch) | |
tree | 6dc32dce7196d1d90863eb6ea4b82a98e680b645 /examples | |
parent | f419fcb431f1896899c3712856908b26e5916e54 (diff) |
examples/gl_basic: Check if api is supported before dlsym'ing
Check if the display supports the requested api before trying to dlsym
that api's library. Thus we avoid trying to dlsym a library that may not
be present on the system.
Improves error messages in `gl_basic cgl gles1` and `gl_basic cgl gles2`.
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/gl_basic.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/examples/gl_basic.c b/examples/gl_basic.c index eb6a944..6f01001 100644 --- a/examples/gl_basic.c +++ b/examples/gl_basic.c @@ -372,6 +372,15 @@ main(int argc, char **argv) if (!ok) error_waffle(); + dpy = waffle_display_connect(opts.display_name); + if (!dpy) + error_waffle(); + + if (!waffle_display_supports_context_api(dpy, opts.context_api)) { + gl_basic_error("Display does not support %s", + waffle_enum_to_string(opts.context_api)); + } + glClear = waffle_dl_sym(opts.dl, "glClear"); if (!glClear) error_get_gl_symbol("glClear"); @@ -384,15 +393,6 @@ main(int argc, char **argv) if (!glReadPixels) error_get_gl_symbol("glReadPixels"); - dpy = waffle_display_connect(opts.display_name); - if (!dpy) - error_waffle(); - - if (!waffle_display_supports_context_api(dpy, opts.context_api)) { - gl_basic_error("Display does not support %s", - waffle_enum_to_string(opts.context_api)); - } - i = 0; config_attrib_list[i++] = WAFFLE_CONTEXT_API; config_attrib_list[i++] = opts.context_api; |