Use git instead of clone to download OpenGL registry.

Core-profile extension query patch by Carsten Neumann
https://sourceforge.net/p/glew/bugs/174/
This commit is contained in:
Nigel Stewart 2013-07-14 13:02:16 -05:00
parent 477c99177a
commit 974679c6d8
7 changed files with 182 additions and 64 deletions

View File

@ -11,11 +11,15 @@ include ../config/version
SHELL = bash SHELL = bash
### Use git repository for GL extension specifications
GIT_CLONE ?= git clone --branch glew https://github.com/nigels-com/glfixes.git
### ###
### Conventional desktop OpenGL settings ### Conventional desktop OpenGL settings
### ###
REGISTRY = registry/gl REGISTRY = registry/gl/specs
EXT = extensions/gl EXT = extensions/gl
FILTER = filter_gl_ext.sh FILTER = filter_gl_ext.sh
CORE = core/gl CORE = core/gl
@ -38,11 +42,11 @@ BLACKLIST = blacklist
GL_CORE_SPEC := $(CORE)/GL_VERSION* GL_CORE_SPEC := $(CORE)/GL_VERSION*
GLX_CORE_SPEC := $(CORE)/GLX_VERSION* GLX_CORE_SPEC := $(CORE)/GLX_VERSION*
ifeq (custom,$(MAKECMDGOALS)) ifeq (custom,$(MAKECMDGOALS))
#GL_CORE_SPEC := $(shell grep GL_VERSION custom.txt | sed 's/\(.*\)/$(CORE)\/\1/g;') #GL_CORE_SPEC := $(shell grep GL_VERSION custom.txt | perl -pi -e "s=^=$(CORE)/=g;")
GL_EXT_SPEC := $(shell grep "^[ \t]*GL_" custom.txt | grep -v GL_VERSION | sed 's/\(.*\)/$(EXT)\/\1/g;') GL_EXT_SPEC := $(shell grep "^[ \t]*GL_" custom.txt | grep -v GL_VERSION | perl -pi -e "s=^=$(EXT)/=g;")
WGL_EXT_SPEC := $(shell grep "^[ \t]*WGL_" custom.txt | sed 's/\(.*\)/$(EXT)\/\1/g;') WGL_EXT_SPEC := $(shell grep "^[ \t]*WGL_" custom.txt | perl -pi -e "s=^=$(EXT)/=g;")
#GLX_CORE_SPEC := $(shell grep GLX_VERSION custom.txt | sed 's/\(.*\)/$(CORE)\/\1/g;') #GLX_CORE_SPEC := $(shell grep GLX_VERSION custom.txt | perl -pi -e "s=^=$(CORE)/=g;")
GLX_EXT_SPEC := $(shell grep "^[ \t]*GLX_" custom.txt | grep -v GLX_VERSION | sed 's/\(.*\)/$(EXT)\/\1/g;') GLX_EXT_SPEC := $(shell grep "^[ \t]*GLX_" custom.txt | grep -v GLX_VERSION | perl -pi -e "s=^=$(EXT)/=g;")
else else
GL_EXT_SPEC := $(EXT)/GL_* GL_EXT_SPEC := $(EXT)/GL_*
WGL_EXT_SPEC := $(EXT)/WGL_* WGL_EXT_SPEC := $(EXT)/WGL_*
@ -97,11 +101,11 @@ all custom: $(I.TARGETS) $(S.TARGETS) $(D.TARGETS) $(B.TARGETS)
registry: $(REGISTRY)/.dummy registry: $(REGISTRY)/.dummy
ext: $(EXT)/.dummy ext: $(EXT)/.dummy
$(REGISTRY)/.dummy: $(BIN)/update_registry.sh $(REGISTRY)/.dummy:
@echo "--------------------------------------------------------------------" @echo "--------------------------------------------------------------------"
@echo "Downloading registry" @echo "Downloading registry"
@echo "--------------------------------------------------------------------" @echo "--------------------------------------------------------------------"
$(BIN)/update_registry.sh $(REGISTRY) $(REGISTRY_URL) $(GIT_CLONE) registry
touch $@ touch $@
$(EXT)/.dummy: $(REGISTRY)/.dummy $(EXT)/.dummy: $(REGISTRY)/.dummy
@ -138,7 +142,7 @@ $(I.DEST)/glew.h: $(EXT)/.dummy
echo -e "\n#if defined(GLEW_MX) && !defined(_WIN32)\nstruct GLEWContextStruct\n{\n#endif /* GLEW_MX */\n" >> $@ echo -e "\n#if defined(GLEW_MX) && !defined(_WIN32)\nstruct GLEWContextStruct\n{\n#endif /* GLEW_MX */\n" >> $@
$(BIN)/make_struct_var.pl GLEW_VAR_EXPORT $(GL_CORE_SPEC) $(GL_EXT_SPEC) >> $@ $(BIN)/make_struct_var.pl GLEW_VAR_EXPORT $(GL_CORE_SPEC) $(GL_EXT_SPEC) >> $@
echo -e "\n#ifdef GLEW_MX\n}; /* GLEWContextStruct */\n#endif /* GLEW_MX */\n" >> $@ echo -e "\n#ifdef GLEW_MX\n}; /* GLEWContextStruct */\n#endif /* GLEW_MX */\n" >> $@
perl -e 's/GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2;/GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_1;\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2;/' -pi $@ perl -e "s/GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2;/GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_1;\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2;/" -pi $@
rm -f $@.bak rm -f $@.bak
cat $(SRC)/glew_tail.h >> $@ cat $(SRC)/glew_tail.h >> $@
@ -165,14 +169,14 @@ $(I.DEST)/glxew.h: $(EXT)/.dummy
cat $(SRC)/mesa_license.h >> $@ cat $(SRC)/mesa_license.h >> $@
cat $(SRC)/khronos_license.h >> $@ cat $(SRC)/khronos_license.h >> $@
cat $(SRC)/glxew_head.h >> $@ cat $(SRC)/glxew_head.h >> $@
$(BIN)/make_header.pl '' GLX $(GLX_CORE_SPEC) >> $@ $(BIN)/make_header.pl "" GLX $(GLX_CORE_SPEC) >> $@
$(BIN)/make_header.pl '' GLX $(GLX_EXT_SPEC) >> $@ $(BIN)/make_header.pl "" GLX $(GLX_EXT_SPEC) >> $@
cat $(SRC)/glxew_mid.h >> $@ cat $(SRC)/glxew_mid.h >> $@
$(BIN)/make_struct_fun.pl GLXEW_FUN_EXPORT $(GLX_CORE_SPEC) $(GLX_EXT_SPEC) >> $@ $(BIN)/make_struct_fun.pl GLXEW_FUN_EXPORT $(GLX_CORE_SPEC) $(GLX_EXT_SPEC) >> $@
echo -e "\n#if defined(GLEW_MX)\nstruct GLXEWContextStruct\n{\n#endif /* GLEW_MX */\n" >> $@ echo -e "\n#if defined(GLEW_MX)\nstruct GLXEWContextStruct\n{\n#endif /* GLEW_MX */\n" >> $@
$(BIN)/make_struct_var.pl GLXEW_VAR_EXPORT $(GLX_CORE_SPEC) $(GLX_EXT_SPEC) >> $@ $(BIN)/make_struct_var.pl GLXEW_VAR_EXPORT $(GLX_CORE_SPEC) $(GLX_EXT_SPEC) >> $@
echo -e "\n#ifdef GLEW_MX\n}; /* GLXEWContextStruct */\n#endif /* GLEW_MX */\n" >> $@ echo -e "\n#ifdef GLEW_MX\n}; /* GLXEWContextStruct */\n#endif /* GLEW_MX */\n" >> $@
perl -e 's/GLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_2;/GLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_0;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_1;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_2;/' -pi $@ perl -e "s/GLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_2;/GLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_0;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_1;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_2;/" -pi $@
cat $(SRC)/glxew_tail.h >> $@ cat $(SRC)/glxew_tail.h >> $@
$(S.DEST)/glew.c: $(EXT)/.dummy $(S.DEST)/glew.c: $(EXT)/.dummy
@ -193,8 +197,9 @@ $(S.DEST)/glew.c: $(EXT)/.dummy
$(BIN)/make_init.pl GL $(GL_CORE_SPEC) >> $@ $(BIN)/make_init.pl GL $(GL_CORE_SPEC) >> $@
$(BIN)/make_init.pl GL $(GL_EXT_SPEC) >> $@ $(BIN)/make_init.pl GL $(GL_EXT_SPEC) >> $@
cat $(SRC)/glew_init_gl.c >> $@ cat $(SRC)/glew_init_gl.c >> $@
$(BIN)/make_list.pl $(GL_CORE_SPEC) | grep -v '\"GL_VERSION' >> $@ $(BIN)/make_list_gl.pl $(GL_CORE_SPEC) | grep -v '\"GL_VERSION' >> $@
$(BIN)/make_list.pl $(GL_EXT_SPEC) >> $@ cat $(SRC)/glew_init_gl_2.c >> $@
$(BIN)/make_list_gl.pl $(GL_EXT_SPEC) >> $@
echo -e "\n return GLEW_OK;\n}\n" >> $@ echo -e "\n return GLEW_OK;\n}\n" >> $@
echo -e "\n#if defined(_WIN32)" >> $@ echo -e "\n#if defined(_WIN32)" >> $@
echo -e "\n#if !defined(GLEW_MX)" >> $@ echo -e "\n#if !defined(GLEW_MX)" >> $@
@ -270,6 +275,7 @@ $(S.DEST)/glew_init.c: $(EXT)/.dummy
$(BIN)/make_init.pl GL $(GL_EXT_SPEC) >> $@ $(BIN)/make_init.pl GL $(GL_EXT_SPEC) >> $@
cat $(SRC)/glew_init_gl.c >> $@ cat $(SRC)/glew_init_gl.c >> $@
$(BIN)/make_list.pl $(GL_CORE_SPEC) | grep -v '\"GL_VERSION' >> $@ $(BIN)/make_list.pl $(GL_CORE_SPEC) | grep -v '\"GL_VERSION' >> $@
cat $(SRC)/glew_init_gl_2.c >> $@
$(BIN)/make_list.pl $(GL_EXT_SPEC) >> $@ $(BIN)/make_list.pl $(GL_EXT_SPEC) >> $@
echo -e "\n return GLEW_OK;\n}\n\n#if defined(_WIN32)\n" >> $@; echo -e "\n return GLEW_OK;\n}\n\n#if defined(_WIN32)\n" >> $@;
$(BIN)/make_init.pl WGL $(WGL_EXT_SPEC) >> $@ $(BIN)/make_init.pl WGL $(WGL_EXT_SPEC) >> $@
@ -382,4 +388,4 @@ clobber: clean
rm -rf $(EXT) rm -rf $(EXT)
destroy: clobber destroy: clobber
rm -rf $(REGISTRY) rm -rf registry

66
auto/bin/make_list_gl.pl Executable file
View File

@ -0,0 +1,66 @@
#!/usr/bin/perl
##
## Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
## Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
##
## This program is distributed under the terms and conditions of the GNU
## General Public License Version 2 as published by the Free Software
## Foundation or, at your option, any later version.
use strict;
use warnings;
do 'bin/make.pl';
#---------------------------------------------------------------------------------------
# function pointer definition
sub make_init_call($%)
{
my $name = prefixname($_[0]);
return " r = r || (" . $_[0] . " = (PFN" . (uc $_[0]) . "PROC)glewGetProcAddress(\"" . $name . "\")) == NULL;";
}
#---------------------------------------------------------------------------------------
my @extlist = ();
my %extensions = ();
if (@ARGV)
{
@extlist = @ARGV;
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) = parse_ext($ext);
my $extvar = $extname;
$extvar =~ s/GL(X*)_/GL$1EW_/;
my $extpre = $extname;
$extpre =~ s/^(W?)GL(X?).*$/\l$1gl\l$2ew/;
#my $pextvar = prefix_varname($extvar);
print "#ifdef $extname\n";
if (length($extstring))
{
print " CONST_CAST(" . $extvar . ") = _glewSearchExtensionArray(\"$extstring\", extArrayStart, extArrayEnd);\n";
}
if (keys %$functions)
{
if ($extname =~ /WGL_.*/)
{
print " if (glewExperimental || " . $extvar . "|| crippled) CONST_CAST(" . $extvar . ")= !_glewInit_$extname(GLEW_CONTEXT_ARG_VAR_INIT);\n";
}
else
{
print " if (glewExperimental || " . $extvar . ") CONST_CAST(" . $extvar . ") = !_glewInit_$extname(GLEW_CONTEXT_ARG_VAR_INIT);\n";
}
}
print "#endif /* $extname */\n";
}
}

View File

@ -307,8 +307,7 @@ my @speclist = ();
my %extensions = (); my %extensions = ();
my $ext_dir = shift; my $ext_dir = shift;
my $reg_http = "http://www.opengl.org/registry/specs/"; my $reg_http = "http://www.opengl.org/registry/specs/gl/";
#my $reg_http = "http://oss.sgi.com/projects/ogl-sample/";
# Take command line arguments or read list from file # Take command line arguments or read list from file
if (@ARGV) if (@ARGV)
@ -329,7 +328,7 @@ foreach my $spec (sort @speclist)
open EXT, ">$info"; open EXT, ">$info";
print EXT $ext . "\n"; # Extension name print EXT $ext . "\n"; # Extension name
my $specname = $spec; my $specname = $spec;
$specname =~ s/registry\///; $specname =~ s/registry\/gl\/specs\///;
print EXT $reg_http . $specname . "\n"; # Extension info URL print EXT $reg_http . $specname . "\n"; # Extension info URL
print EXT $ext . "\n"; # Extension string print EXT $ext . "\n"; # Extension string

View File

@ -1,33 +0,0 @@
#!/bin/sh
##
## Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
## Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
##
## This program is distributed under the terms and conditions of the GNU
## General Public License Version 2 as published by the Free Software
## Foundation or, at your option, any later version.
set -e
if [ ! -d $1 ] ; then
mkdir -p $1
fi
cd $1
# wget used to return 0 (success), but more recent versions
# don't so we don't want to bail out in failure mode
# eventhough everything is fine.
set +e
wget \
--mirror \
--no-parent \
--no-host-directories \
--cut-dirs=2 \
--accept=txt,html \
$2
echo 'wget exit code: ' $?
exit 0

View File

@ -247,3 +247,18 @@ static GLboolean _glewSearchExtension (const char* name, const GLubyte *start, c
} }
return GL_FALSE; return GL_FALSE;
} }
static GLboolean _glewSearchExtensionArray (const char* name, const GLubyte** start, const GLubyte** end)
{
const GLubyte** p;
GLuint len = _glewStrLen((const GLubyte*)name);
p = start;
while (p < end)
{
GLuint n = _glewStrCLen(*p, ' ');
if (len == n && _glewStrSame((const GLubyte*)name, *p, n)) return GL_TRUE;
p += 1;
}
return GL_FALSE;
}

View File

@ -4,12 +4,36 @@ GLboolean GLEWAPIENTRY glewGetExtension (const char* name)
{ {
const GLubyte* start; const GLubyte* start;
const GLubyte* end; const GLubyte* end;
GLuint dot;
GLint numExt, i, major;
/* query opengl version to decide how to enumerate extensions */
start = glGetString(GL_VERSION);
dot = _glewStrCLen(start, '.');
if (dot == 0)
return GL_FALSE;
major = start[dot-1]-'0';
if (major >= 3)
{
glGetIntegerv(GL_NUM_EXTENSIONS, &numExt);
for(i = 0; i < numExt; ++i)
{
start = glGetStringi(GL_EXTENSIONS, i);
end = start + _glewStrLen(start);
if(_glewSearchExtension(name, start, end) == GL_TRUE)
return GL_TRUE;
}
}
else
{
start = (const GLubyte*)glGetString(GL_EXTENSIONS); start = (const GLubyte*)glGetString(GL_EXTENSIONS);
if (start == 0) if (start == 0)
return GL_FALSE; return GL_FALSE;
end = start + _glewStrLen(start); end = start + _glewStrLen(start);
return _glewSearchExtension(name, start, end); return _glewSearchExtension(name, start, end);
} }
return GL_FALSE;
}
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
@ -21,6 +45,9 @@ GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
const GLubyte* s; const GLubyte* s;
GLuint dot; GLuint dot;
GLint major, minor; GLint major, minor;
const GLubyte* extArray[1000];
const GLubyte** extArrayStart;
const GLubyte** extArrayEnd;
const GLubyte* extStart; const GLubyte* extStart;
const GLubyte* extEnd; const GLubyte* extEnd;
/* query opengl version */ /* query opengl version */
@ -62,10 +89,4 @@ GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
CONST_CAST(GLEW_VERSION_1_1) = GLEW_VERSION_1_2 == GL_TRUE || ( major == 1 && minor >= 1 ) ? GL_TRUE : GL_FALSE; CONST_CAST(GLEW_VERSION_1_1) = GLEW_VERSION_1_2 == GL_TRUE || ( major == 1 && minor >= 1 ) ? GL_TRUE : GL_FALSE;
} }
/* query opengl extensions string */ /* initialize core */
extStart = glGetString(GL_EXTENSIONS);
if (extStart == 0)
extStart = (const GLubyte*)"";
extEnd = extStart + _glewStrLen(extStart);
/* initialize extensions */

44
auto/src/glew_init_gl_2.c Normal file
View File

@ -0,0 +1,44 @@
/* get extensions */
if (GLEW_VERSION_3_0 == GL_TRUE)
{
GLint numExt;
GLint i;
glGetIntegerv(GL_NUM_EXTENSIONS, &numExt);
for(i = 0; i < numExt; ++i)
{
extArray[i] = glGetStringi(GL_EXTENSIONS, i);
}
extArrayStart = &extArray[0];
extArrayEnd = &extArray[i];
}
else
{
int i;
extStart = glGetString(GL_EXTENSIONS);
if (extStart == 0)
extStart = (const GLubyte*)"";
extEnd = extStart + _glewStrLen(extStart);
i = 0;
while (extStart < extEnd)
{
int len = _glewStrCLen(extStart, ' ');
if (len > 0)
{
extArray[i] = extStart;
i += 1;
}
extStart += len + 1;
}
extArrayStart = &extArray[0];
extArrayEnd = &extArray[i];
}
/* initialize extensions */