[waffle] [RFC 2/3] wflinfo.c: split version, renderer, and vendor checks
baker.dylan.c at gmail.com
baker.dylan.c at gmail.com
Wed Dec 16 17:37:02 PST 2015
From: Dylan Baker <baker.dylan.c at gmail.com>
Pull these out into helper functions, this change will be used in a
following patch to add a json printer.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
src/utils/wflinfo.c | 50 ++++++++++++++++++++++++++++++++++++--------------
1 file changed, 36 insertions(+), 14 deletions(-)
diff --git a/src/utils/wflinfo.c b/src/utils/wflinfo.c
index 905fd90..b843757 100644
--- a/src/utils/wflinfo.c
+++ b/src/utils/wflinfo.c
@@ -458,6 +458,39 @@ parse_version(const char *version)
return (major * 10) + minor;
}
+static const char *
+get_vendor(void)
+{
+ const char *vendor = (const char *) glGetString(GL_VENDOR);
+ if (glGetError() != GL_NO_ERROR || vendor == NULL) {
+ vendor = "WFLINFO_GL_ERROR";
+ }
+
+ return vendor;
+}
+
+static const char *
+get_renderer(void)
+{
+ const char *renderer = (const char *) glGetString(GL_RENDERER);
+ if (glGetError() != GL_NO_ERROR || renderer == NULL) {
+ renderer = "WFLINFO_GL_ERROR";
+ }
+
+ return renderer;
+}
+
+static const char *
+get_version(void)
+{
+ const char *version_str = (const char *) glGetString(GL_VERSION);
+ if (glGetError() != GL_NO_ERROR || version_str == NULL) {
+ version_str = "WFLINFO_GL_ERROR";
+ }
+
+ return version_str;
+}
+
static void
print_extensions(bool use_stringi)
{
@@ -539,20 +572,9 @@ print_wflinfo(const struct options *opts)
/* Clear all errors */
}
- const char *vendor = (const char *) glGetString(GL_VENDOR);
- if (glGetError() != GL_NO_ERROR || vendor == NULL) {
- vendor = "WFLINFO_GL_ERROR";
- }
-
- const char *renderer = (const char *) glGetString(GL_RENDERER);
- if (glGetError() != GL_NO_ERROR || renderer == NULL) {
- renderer = "WFLINFO_GL_ERROR";
- }
-
- const char *version_str = (const char *) glGetString(GL_VERSION);
- if (glGetError() != GL_NO_ERROR || version_str == NULL) {
- version_str = "WFLINFO_GL_ERROR";
- }
+ const char * vendor = get_vendor();
+ const char * renderer = get_renderer();
+ const char * version_str = get_version();
const char *platform = enum_map_to_str(platform_map, opts->platform);
assert(platform != NULL);
--
2.6.4
More information about the waffle
mailing list