fixed problems with WGL_{ARB,EXT}_extensions_string

git-svn-id: https://glew.svn.sourceforge.net/svnroot/glew/trunk/glew@117 783a27ee-832a-0410-bc00-9f386506c6dd
This commit is contained in:
ikits 2003-09-12 03:50:22 +00:00
parent 644fa321b4
commit ac0c6387e9
8 changed files with 59 additions and 47 deletions

View File

@ -32,7 +32,7 @@ GLEW_DEST ?= /usr
GLEW_MAJOR = 1 GLEW_MAJOR = 1
GLEW_MINOR = 1 GLEW_MINOR = 1
GLEW_MICRO = 1 GLEW_MICRO = 2
GLEW_VERSION = $(GLEW_MAJOR).$(GLEW_MINOR).$(GLEW_MICRO) GLEW_VERSION = $(GLEW_MAJOR).$(GLEW_MINOR).$(GLEW_MICRO)
TARDIR = ../glew-$(GLEW_VERSION) TARDIR = ../glew-$(GLEW_VERSION)

View File

@ -6,20 +6,25 @@
# General Public License Version 2 as published by the Free Software # General Public License Version 2 as published by the Free Software
# Foundation or, at your option, any later version. # Foundation or, at your option, any later version.
SHELL := bash GLEW_MAJOR = 1
REGISTRY := registry GLEW_MINOR = 1
BIN := bin GLEW_MICRO = 2
SRC := src GLEW_VERSION = $(GLEW_MAJOR).$(GLEW_MINOR).$(GLEW_MICRO)
CORE := core
EXT := extensions
BLACKLIST := blacklist
PARSE_SPEC := parse_spec.pl SHELL = bash
REGISTRY = registry
BIN = bin
SRC = src
CORE = core
EXT = extensions
BLACKLIST = blacklist
TOP := .. PARSE_SPEC = parse_spec.pl
I.DEST := $(TOP)/include/GL
S.DEST := $(TOP)/src TOP = ..
D.DEST := $(TOP)/doc I.DEST = $(TOP)/include/GL
S.DEST = $(TOP)/src
D.DEST = $(TOP)/doc
TARGETS = $(I.DEST)/glew.h $(I.DEST)/wglew.h $(I.DEST)/glxew.h $(S.DEST)/glew.c $(S.DEST)/glewinfo.c $(D.DEST)/glew.html $(D.DEST)/wglew.html $(D.DEST)/glxew.html TARGETS = $(I.DEST)/glew.h $(I.DEST)/wglew.h $(I.DEST)/glxew.h $(S.DEST)/glew.c $(S.DEST)/glewinfo.c $(D.DEST)/glew.html $(D.DEST)/wglew.html $(D.DEST)/glxew.html
@ -84,6 +89,7 @@ $(S.DEST)/glew.c: $(EXT)/.dummy
$(BIN)/make_list.pl $(EXT)/GLX_* >> $@ $(BIN)/make_list.pl $(EXT)/GLX_* >> $@
cat $(SRC)/glew_post.c >> $@ cat $(SRC)/glew_post.c >> $@
$(BIN)/fix_OML_sync_control.sh $@ $(BIN)/fix_OML_sync_control.sh $@
sed -i -e "s/GLEW_VERSION_STRING/$(GLEW_MAJOR)\.$(GLEW_MINOR)\.$(GLEW_MICRO)/g" $@
$(S.DEST)/glewinfo.c: $(EXT)/.dummy $(S.DEST)/glewinfo.c: $(EXT)/.dummy
cp -f $(SRC)/glewinfo_pre.c $@ cp -f $(SRC)/glewinfo_pre.c $@

View File

@ -32,7 +32,7 @@ static int _glewStrSame (const char *a, const char *b, int n)
* other extension names. Could use strtok() but the constant * other extension names. Could use strtok() but the constant
* string returned by glGetString might be in read-only memory. * string returned by glGetString might be in read-only memory.
*/ */
GLboolean glewGetExtension (const char *name) GLboolean glewGetExtension (const GLubyte *name)
{ {
char *p, *end; char *p, *end;
int len = _glewStrLen(name); int len = _glewStrLen(name);

View File

@ -5,28 +5,38 @@
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
const char* glewGetErrorString (GLuint error) const GLubyte* glewGetErrorString (GLenum error)
{ {
static const char* _glewErrorString[] = static const GLubyte* _glewErrorString[] =
{ {
"no error", "no error",
"missing GL version", "missing GL version",
"missing {ARB,EXT}_extensions_string",
"GL 1.1 and up are not supported", "GL 1.1 and up are not supported",
"GLX 1.2 and up are not supported", "GLX 1.2 and up are not supported",
"unknown error" "unknown error"
}; };
if (error > 5) error = 5; if (error > sizeof(_glewErrorString)) error = sizeof(_glewErrorString);
return _glewErrorString[error]; return _glewErrorString[error];
} }
const GLubyte* glewGetString (GLenum name)
{
static const GLubyte* _glewString[] =
{
NULL,
"GLEW_VERSION_STRING"
};
if (name > sizeof(_glewString)-1) return NULL;
return _glewString[name];
}
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
GLboolean glewExperimental = GL_FALSE; GLboolean glewExperimental = GL_FALSE;
GLuint glewInit () GLenum glewInit ()
{ {
GLuint r; GLenum r;
if ( (r = _glewInit()) ) return r; if ( (r = _glewInit()) ) return r;
#ifdef _WIN32 #ifdef _WIN32
return _wglewInit(); return _wglewInit();

View File

@ -2,16 +2,20 @@
/* error codes */ /* error codes */
#define GLEW_OK 0 #define GLEW_OK 0
#define GLEW_NO_ERROR 0
#define GLEW_ERROR_NO_GL_VERSION 1 /* missing GL version */ #define GLEW_ERROR_NO_GL_VERSION 1 /* missing GL version */
#define GLEW_ERROR_NO_EXTENSIONS_STRING 2 /* missing {ARB,EXT}_extensions_string */ #define GLEW_ERROR_GL_VERSION_10_ONLY 2 /* GL 1.1 and up are not supported */
#define GLEW_ERROR_GL_VERSION_10_ONLY 3 /* GL 1.1 and up are not supported */ #define GLEW_ERROR_GLX_VERSION_11_ONLY 3 /* GLX 1.2 and up are not supported */
#define GLEW_ERROR_GLX_VERSION_11_ONLY 4 /* GLX 1.2 and up are not supported */
/* string codes */
#define GLEW_VERSION 1
/* API */ /* API */
GLEWAPI GLboolean glewExperimental; GLEWAPI GLboolean glewExperimental;
GLEWAPI GLuint glewInit (); GLEWAPI GLenum glewInit ();
GLEWAPI GLboolean glewGetExtension (const char* name); GLEWAPI GLboolean glewGetExtension (const GLubyte* name);
GLEWAPI const char* glewGetErrorString (GLuint error); GLEWAPI const GLubyte* glewGetErrorString (GLenum error);
GLEWAPI const GLubyte* glewGetString (GLenum name);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -48,28 +48,21 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
static void * __dlopenGetProcAddress(const GLubyte *procName) static void* __dlopenGetProcAddress (const GLubyte *procName)
{ {
static void *h = NULL; static void *h = NULL;
static void *gpa; static void *gpa;
if (!h) if (!h)
{ {
if (!(h = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL))) if (!(h = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL))) return NULL;
{ gpa = dlsym(h, "glXGetProcAddress");
fprintf(stderr, }
"E: GLEW failed to dlopen myself: %s.\nAbort.\n",
dlerror());
exit(100);
}
gpa = dlsym(h, "glXGetProcAddress"); if (gpa != NULL)
} return ((void* (*)(const GLubyte*))gpa)(procName);
else
if (gpa != NULL) return dlsym(h, (const char *)procName);
return ((void* (*)(const GLubyte*))gpa)(procName);
else
return dlsym(h, (const char *)procName);
} }
#endif /* GLEW_NEEDS_CUSTOM_GET_PROCADDRESS */ #endif /* GLEW_NEEDS_CUSTOM_GET_PROCADDRESS */

View File

@ -34,6 +34,4 @@ static GLuint _wglewInit ()
WGLEW_ARB_extensions_string = wglGetExtensionsStringARB != NULL; WGLEW_ARB_extensions_string = wglGetExtensionsStringARB != NULL;
_glewInit_WGL_EXT_extensions_string(); _glewInit_WGL_EXT_extensions_string();
WGLEW_EXT_extensions_string = wglGetExtensionsStringEXT != NULL; WGLEW_EXT_extensions_string = wglGetExtensionsStringEXT != NULL;
if (WGLEW_ARB_extensions_string == GL_FALSE &&
WGLEW_EXT_extensions_string == GL_FALSE) return GLEW_ERROR_NO_EXTENSIONS_STRING;
/* initialize extensions */ /* initialize extensions */

View File

@ -28,6 +28,7 @@ int main (int argc, char** argv)
fprintf(f, "Running on a %s from %s\n", fprintf(f, "Running on a %s from %s\n",
glGetString(GL_RENDERER), glGetString(GL_VENDOR)); glGetString(GL_RENDERER), glGetString(GL_VENDOR));
fprintf(f, "OpenGL version %s is supported\n", glGetString(GL_VERSION)); fprintf(f, "OpenGL version %s is supported\n", glGetString(GL_VERSION));
fprintf(f, "GLEW version %s is supported\n", glewGetString(GLEW_VERSION));
glewInfo(); glewInfo();
#ifdef _WIN32 #ifdef _WIN32
wglewInfo(); wglewInfo();