]> git.cworth.org Git - glenv/commitdiff
Implement --query option
authorCarl Worth <cworth@cworth.org>
Wed, 4 Sep 2013 23:46:07 +0000 (16:46 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 4 Sep 2013 23:46:07 +0000 (16:46 -0700)
This depends on the function recently added to glaze:

glaze_set_first_glcall_callback

So that once there's a valid GL context, glenv can query it to
determine the environment and report that.

glenv.c
glwrap.c

diff --git a/glenv.c b/glenv.c
index 824b8b8bfaf697a3131added5ca149c2a1fbbaf3..6d27ad4bf402b6d380d619bb9730b50443714c76 100644 (file)
--- a/glenv.c
+++ b/glenv.c
@@ -41,10 +41,9 @@ typedef struct options {
 static void
 export_options (options_t *options)
 {
 static void
 export_options (options_t *options)
 {
-       if (options->query)
-               setenv ("GLENV_QUERY", "1", 1);
-       else
-               unsetenv ("GLENV_QUERY");
+       if (options->query) {
+               glaze_set_first_gl_call_callback ("glenv_query");
+       }
 
        if (options->vendor)
                setenv ("GLENV_GL_VENDOR", options->vendor, 1);
 
        if (options->vendor)
                setenv ("GLENV_GL_VENDOR", options->vendor, 1);
index faf6a81ef3285ec0814e34d99e87bebdc2a6b854..9c9f3093b304078438d2e212a5c52d84473513e9 100644 (file)
--- a/glwrap.c
+++ b/glwrap.c
 #include <stdlib.h>
 #include <string.h>
 
 #include <stdlib.h>
 #include <string.h>
 
+void glenv_query (void);
+
+typedef GLubyte * (get_string_type_t) (GLenum);
+
+void
+glenv_query (void)
+{
+       printf ("--vendor=\"%s\"\n", glGetString (GL_VENDOR));
+       printf ("--renderer=\"%s\"\n", glGetString (GL_RENDERER));
+       printf ("--version=\"%s\"\n", glGetString (GL_VERSION));
+       printf ("--shading-language-version=\"%s\"\n", glGetString (GL_SHADING_LANGUAGE_VERSION));
+       printf ("--extensions=\"%s\"\n", glGetString (GL_EXTENSIONS));
+
+       exit (0);
+}
+
 static int
 glenv_num_extensions (void)
 {
 static int
 glenv_num_extensions (void)
 {