mirror of
https://github.com/nigels-com/glew.git
synced 2024-11-28 08:41:55 +00:00
Load core function pointers before checking the extension string.
For GL versions since 3.0 the glGetString() function is deprecated or removed, and the right way to query extensions is glGetStringi(), but that has to be loaded first. Also instead of searching the whole extension string n times lookup the known extensions in a static hash table. The hash table is built with the gperf utility.
This commit is contained in:
parent
dd6e034cba
commit
e935fcad83
@ -183,7 +183,16 @@ $(I.DEST)/glxew.h: $(EXT)/.dummy
|
||||
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 >> $@
|
||||
|
||||
$(S.DEST)/glew.c: $(EXT)/.dummy
|
||||
$(SRC)/glew.gperf: $(EXT)/.dummy
|
||||
@echo "--------------------------------------------------------------------"
|
||||
@echo "Creating glew.gperf"
|
||||
@echo "--------------------------------------------------------------------"
|
||||
$(BIN)/make_gperf.pl $(GL_EXT_SPEC) $(WGL_EXT_SPEC) $(GLX_EXT_SPEC) > $@
|
||||
|
||||
$(SRC)/glew_init_hash.c: $(SRC)/glew.gperf
|
||||
gperf -m 10 --output-file=$@ $(SRC)/glew.gperf
|
||||
|
||||
$(S.DEST)/glew.c: $(EXT)/.dummy $(SRC)/glew_init_hash.c
|
||||
@echo "--------------------------------------------------------------------"
|
||||
@echo "Creating glew.c"
|
||||
@echo "--------------------------------------------------------------------"
|
||||
@ -209,8 +218,10 @@ $(S.DEST)/glew.c: $(EXT)/.dummy
|
||||
echo -e "" >> $@;
|
||||
$(BIN)/make_init.pl GL $(GL_CORE_SPEC) >> $@
|
||||
$(BIN)/make_init.pl GL $(GL_EXT_SPEC) >> $@
|
||||
cat $(SRC)/glew_init_hash.c | grep -v '^#line' >> $@
|
||||
cat $(SRC)/glew_init_gl.c >> $@
|
||||
$(BIN)/make_list.pl $(GL_CORE_SPEC) | grep -v '\"GL_VERSION' >> $@
|
||||
$(BIN)/make_list.pl $(GL_CORE_SPEC) >> $@
|
||||
cat $(SRC)/glew_init_glext.c >> $@
|
||||
$(BIN)/make_list.pl $(GL_EXT_SPEC) >> $@
|
||||
echo -e "\n return GLEW_OK;\n}\n" >> $@
|
||||
echo -e "\n#if defined(_WIN32) && ! defined(GLEW_OSMESA)" >> $@
|
||||
|
41
auto/bin/make_gperf.pl
Executable file
41
auto/bin/make_gperf.pl
Executable file
@ -0,0 +1,41 @@
|
||||
#!/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';
|
||||
|
||||
my @extlist = ();
|
||||
my %extensions = ();
|
||||
|
||||
our $type = shift;
|
||||
|
||||
if (@ARGV)
|
||||
{
|
||||
@extlist = @ARGV;
|
||||
|
||||
print "%struct-type\n";
|
||||
print "%compare-lengths\n";
|
||||
print "%define initializer-suffix ,NULL\n";
|
||||
print "%7bit\n";
|
||||
print "struct initflag { const char *name; GLboolean *flag; };\n";
|
||||
print "%%\n";
|
||||
|
||||
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 $prefix = $extvar;
|
||||
$prefix =~ s/_.*//;
|
||||
print $extname . ", " . $prefix . "_GET_REF(__" . $extvar . ")\n";
|
||||
}
|
||||
}
|
@ -47,11 +47,6 @@ if (@ARGV)
|
||||
print "#ifdef $extname\n";
|
||||
}
|
||||
|
||||
if (length($extstring) && $extstring !~ /^GL_/)
|
||||
{
|
||||
print " " . $extvar . " = _glewSearchExtension(\"$extstring\", extStart, extEnd);\n";
|
||||
}
|
||||
|
||||
if (keys %$functions)
|
||||
{
|
||||
if ($extname =~ /WGL_.*/)
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include <stdlib.h> /* For malloc, free */
|
||||
#include <string.h> /* For memset */
|
||||
|
||||
extern int memcmp(const void *, const void *, size_t);
|
||||
|
||||
#if defined(GLEW_REGAL)
|
||||
|
||||
/* In GLEW_REGAL mode we call direcly into the linked
|
||||
|
23
auto/src/glew_init_glext.c
Normal file
23
auto/src/glew_init_glext.c
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
/* query opengl extensions string */
|
||||
extStart = glGetString(GL_EXTENSIONS);
|
||||
if (extStart == 0)
|
||||
extStart = (const GLubyte*)"";
|
||||
extEnd = extStart + _glewStrLen(extStart);
|
||||
|
||||
while (extStart < extEnd)
|
||||
{
|
||||
GLuint len = _glewStrCLen(extStart, ' ');
|
||||
struct initflag *ptr = in_word_set(extStart, len);
|
||||
|
||||
if (ptr != NULL && ptr->flag != NULL) {
|
||||
#ifdef GLEW_MX
|
||||
*(GLboolean *)((char *)ctx + (size_t)(ptr->flag)) = GL_TRUE;
|
||||
#else
|
||||
*ptr->flag = GL_TRUE;
|
||||
#endif
|
||||
}
|
||||
extStart += len + 1;
|
||||
}
|
||||
|
||||
/* initialize extensions */
|
@ -50,4 +50,20 @@ GLenum glxewInit ()
|
||||
if (extStart == 0)
|
||||
extStart = (const GLubyte *)"";
|
||||
extEnd = extStart + _glewStrLen(extStart);
|
||||
|
||||
while (extStart < extEnd)
|
||||
{
|
||||
GLuint len = _glewStrCLen(extStart, ' ');
|
||||
struct initflag *ptr = in_word_set(extStart, len);
|
||||
|
||||
if (ptr != NULL && ptr->flag != NULL) {
|
||||
#ifdef GLEW_MX
|
||||
*(GLboolean *)((char *)ctx + (size_t)(ptr->flag)) = GL_TRUE;
|
||||
#else
|
||||
*ptr->flag = GL_TRUE;
|
||||
#endif
|
||||
}
|
||||
extStart += len + 1;
|
||||
}
|
||||
|
||||
/* initialize extensions */
|
||||
|
@ -37,5 +37,21 @@ GLenum GLEWAPIENTRY wglewInit ()
|
||||
else
|
||||
extStart = (const GLubyte*)_wglewGetExtensionsStringARB(wglGetCurrentDC());
|
||||
extEnd = extStart + _glewStrLen(extStart);
|
||||
|
||||
while (extStart < extEnd)
|
||||
{
|
||||
GLuint len = _glewStrCLen(extStart, ' ');
|
||||
struct initflag *ptr = in_word_set(extStart, len);
|
||||
|
||||
if (ptr != NULL && ptr->flag != NULL) {
|
||||
#ifdef GLEW_MX
|
||||
*(GLboolean *)((char *)ctx + (size_t)(ptr->flag)) = GL_TRUE;
|
||||
#else
|
||||
*ptr->flag = GL_TRUE;
|
||||
#endif
|
||||
}
|
||||
extStart += len + 1;
|
||||
}
|
||||
|
||||
/* initialize extensions */
|
||||
crippled = _wglewGetExtensionsStringARB == NULL && _wglewGetExtensionsStringEXT == NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user