From 6f31e134f66e05c02b15cb568d731700374bb91d Mon Sep 17 00:00:00 2001 From: Nigel Stewart Date: Mon, 28 Jan 2019 20:45:01 +1000 Subject: [PATCH] Extend glewinfo to support optional -experimental mode, default to normal mode of operation --- auto/Makefile | 2 +- auto/bin/make_info.pl | 18 ++++++++++++++---- auto/src/glewinfo_head.c | 19 +++++++++++++------ auto/src/glewinfo_tail.c | 15 +++++++++++---- 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/auto/Makefile b/auto/Makefile index 5b855a2..0a2d76e 100644 --- a/auto/Makefile +++ b/auto/Makefile @@ -290,7 +290,7 @@ $(S.DEST)/glewinfo.c: $(EXT)/.dummy $(BIN)/make_info_list.pl $(EGL_CORE_SPEC) >> $@ $(BIN)/make_info_list.pl $(EGL_EXT_SPEC) >> $@ cat $(SRC)/glewinfo_tail.c >> $@ - perl -e 's/"glColorSubTable"/"glBlendEquation", glBlendEquation == NULL);\n glewInfoFunc("glColorSubTable"/g' -pi $@ + perl -e 's/"glColorSubTable"/"glBlendEquation", glBlendEquation == NULL);\n glewInfoFunc(fi, "glColorSubTable"/g' -pi $@ rm -f $@.bak # Update documentation diff --git a/auto/bin/make_info.pl b/auto/bin/make_info.pl index 3aee860..3dcece9 100755 --- a/auto/bin/make_info.pl +++ b/auto/bin/make_info.pl @@ -20,7 +20,7 @@ do 'bin/make.pl'; sub make_pfn_info($%) { my $name = $_[0]; - return " glewInfoFunc(\"$_[0]\", $name == NULL);"; + return " glewInfoFunc(fi, \"$_[0]\", $name == NULL);"; } #--------------------------------------------------------------------------------------- @@ -44,13 +44,23 @@ if (@ARGV) #make_separator($extname); print "#ifdef $extname\n\n"; print "static void _glewInfo_$extname (void)\n{\n"; - if ($extvar =~ /VERSION/) + + if (! %$functions) { - print " glewPrintExt(\"$extname\", $extvar, $extvar, $extvar);\n"; + print " "; } else { - print " glewPrintExt(\"$extname\", $extvar, $extpre" . + print " GLboolean fi = "; + } + + if ($extvar =~ /VERSION/) + { + print "glewPrintExt(\"$extname\", $extvar, $extvar, $extvar);\n"; + } + else + { + print "glewPrintExt(\"$extname\", $extvar, $extpre" . "ewIsSupported(\"$extname\"), $extpre" . "ewGetExtension(\"$extstring\"));\n"; } diff --git a/auto/src/glewinfo_head.c b/auto/src/glewinfo_head.c index 02089f6..79ed785 100644 --- a/auto/src/glewinfo_head.c +++ b/auto/src/glewinfo_head.c @@ -40,6 +40,9 @@ struct createParams /* https://www.opengl.org/registry/specs/ARB/glx_create_context.txt */ int profile; /* core = 1, compatibility = 2 */ int flags; /* debug = 1, forward compatible = 2 */ + + /* GLEW experimental mode */ + int experimental; }; GLboolean glewCreateContext (struct createParams *params); @@ -50,7 +53,7 @@ void glewDestroyContext (); /* ------------------------------------------------------------------------- */ -static void glewPrintExt (const char* name, GLboolean def1, GLboolean def2, GLboolean def3) +static GLboolean glewPrintExt (const char* name, GLboolean def1, GLboolean def2, GLboolean def3) { unsigned int i; fprintf(f, "\n%s:", name); @@ -65,15 +68,19 @@ static void glewPrintExt (const char* name, GLboolean def1, GLboolean def2, GLbo for (i=0; i] " "[-profile core|compatibility] " - "[-flag debug|forward]" + "[-flag debug|forward] " + "[-experimental]" "\n"); return 1; } @@ -52,7 +54,7 @@ int main (int argc, char** argv) glewDestroyContext(); return 1; } - glewExperimental = GL_TRUE; + glewExperimental = params.experimental ? GL_TRUE : GL_FALSE; err = glewInit(); if (GLEW_OK != err) { @@ -162,13 +164,18 @@ GLboolean glewParseArgs (int argc, char** argv, struct createParams *params) { if (++p >= argc) return GL_TRUE; params->display = argv[p++]; - } + } else if (!strcmp(argv[p], "-visual")) { if (++p >= argc) return GL_TRUE; params->visual = (int)strtol(argv[p++], NULL, 0); } #endif + else if (!strcmp(argv[p], "-experimental")) + { + params->experimental = 1; + ++p; + } else return GL_TRUE; }