Extend glewinfo to support optional -experimental mode, default to normal mode of operation

This commit is contained in:
Nigel Stewart 2019-01-28 20:45:01 +10:00
parent e304e73230
commit 6f31e134f6
4 changed files with 39 additions and 15 deletions

View File

@ -290,7 +290,7 @@ $(S.DEST)/glewinfo.c: $(EXT)/.dummy
$(BIN)/make_info_list.pl $(EGL_CORE_SPEC) >> $@ $(BIN)/make_info_list.pl $(EGL_CORE_SPEC) >> $@
$(BIN)/make_info_list.pl $(EGL_EXT_SPEC) >> $@ $(BIN)/make_info_list.pl $(EGL_EXT_SPEC) >> $@
cat $(SRC)/glewinfo_tail.c >> $@ 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 rm -f $@.bak
# Update documentation # Update documentation

View File

@ -20,7 +20,7 @@ do 'bin/make.pl';
sub make_pfn_info($%) sub make_pfn_info($%)
{ {
my $name = $_[0]; my $name = $_[0];
return " glewInfoFunc(\"$_[0]\", $name == NULL);"; return " glewInfoFunc(fi, \"$_[0]\", $name == NULL);";
} }
#--------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------
@ -44,6 +44,16 @@ if (@ARGV)
#make_separator($extname); #make_separator($extname);
print "#ifdef $extname\n\n"; print "#ifdef $extname\n\n";
print "static void _glewInfo_$extname (void)\n{\n"; print "static void _glewInfo_$extname (void)\n{\n";
if (! %$functions)
{
print " ";
}
else
{
print " GLboolean fi = ";
}
if ($extvar =~ /VERSION/) if ($extvar =~ /VERSION/)
{ {
print "glewPrintExt(\"$extname\", $extvar, $extvar, $extvar);\n"; print "glewPrintExt(\"$extname\", $extvar, $extvar, $extvar);\n";

View File

@ -40,6 +40,9 @@ struct createParams
/* https://www.opengl.org/registry/specs/ARB/glx_create_context.txt */ /* https://www.opengl.org/registry/specs/ARB/glx_create_context.txt */
int profile; /* core = 1, compatibility = 2 */ int profile; /* core = 1, compatibility = 2 */
int flags; /* debug = 1, forward compatible = 2 */ int flags; /* debug = 1, forward compatible = 2 */
/* GLEW experimental mode */
int experimental;
}; };
GLboolean glewCreateContext (struct createParams *params); 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; unsigned int i;
fprintf(f, "\n%s:", name); fprintf(f, "\n%s:", name);
@ -65,16 +68,20 @@ static void glewPrintExt (const char* name, GLboolean def1, GLboolean def2, GLbo
for (i=0; i<strlen(name)+1; i++) fprintf(f, "-"); for (i=0; i<strlen(name)+1; i++) fprintf(f, "-");
fprintf(f, "\n"); fprintf(f, "\n");
fflush(f); fflush(f);
return def1 || def2 || def3 || glewExperimental; /* Enable per-function info too? */
} }
static void glewInfoFunc (const char* name, GLint undefined) static void glewInfoFunc (GLboolean fi, const char* name, GLint undefined)
{ {
unsigned int i; unsigned int i;
if (fi)
{
fprintf(f, " %s:", name); fprintf(f, " %s:", name);
for (i=0; i<60-strlen(name); i++) fprintf(f, " "); for (i=0; i<60-strlen(name); i++) fprintf(f, " ");
fprintf(f, "%s\n", undefined ? "MISSING" : "OK"); fprintf(f, "%s\n", undefined ? "MISSING" : "OK");
fflush(f); fflush(f);
} }
}
/* ----------------------------- GL_VERSION_1_1 ---------------------------- */ /* ----------------------------- GL_VERSION_1_1 ---------------------------- */

View File

@ -20,7 +20,8 @@ int main (int argc, char** argv)
0, /* major */ 0, /* major */
0, /* minor */ 0, /* minor */
0, /* profile mask */ 0, /* profile mask */
0 /* flags */ 0, /* flags */
0 /* experimental */
}; };
#if defined(GLEW_EGL) #if defined(GLEW_EGL)
@ -42,6 +43,7 @@ int main (int argc, char** argv)
"[-version <OpenGL version>] " "[-version <OpenGL version>] "
"[-profile core|compatibility] " "[-profile core|compatibility] "
"[-flag debug|forward] " "[-flag debug|forward] "
"[-experimental]"
"\n"); "\n");
return 1; return 1;
} }
@ -52,7 +54,7 @@ int main (int argc, char** argv)
glewDestroyContext(); glewDestroyContext();
return 1; return 1;
} }
glewExperimental = GL_TRUE; glewExperimental = params.experimental ? GL_TRUE : GL_FALSE;
err = glewInit(); err = glewInit();
if (GLEW_OK != err) if (GLEW_OK != err)
{ {
@ -169,6 +171,11 @@ GLboolean glewParseArgs (int argc, char** argv, struct createParams *params)
params->visual = (int)strtol(argv[p++], NULL, 0); params->visual = (int)strtol(argv[p++], NULL, 0);
} }
#endif #endif
else if (!strcmp(argv[p], "-experimental"))
{
params->experimental = 1;
++p;
}
else else
return GL_TRUE; return GL_TRUE;
} }