From 455de90fada991ed423c5cd4f20269fc63653d90 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 4 Sep 2013 16:46:07 -0700 Subject: [PATCH] Implement --query option 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 | 7 +++---- glwrap.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/glenv.c b/glenv.c index 824b8b8..6d27ad4 100644 --- a/glenv.c +++ b/glenv.c @@ -41,10 +41,9 @@ typedef struct 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); diff --git a/glwrap.c b/glwrap.c index faf6a81..9c9f309 100644 --- a/glwrap.c +++ b/glwrap.c @@ -28,6 +28,22 @@ #include #include +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) { -- 2.43.0