diff --git a/Makefile b/Makefile index ecde305..40d5b75 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ GLEW_DEST ?= /usr GLEW_MAJOR = 1 GLEW_MINOR = 1 -GLEW_MICRO = 1 +GLEW_MICRO = 2 GLEW_VERSION = $(GLEW_MAJOR).$(GLEW_MINOR).$(GLEW_MICRO) TARDIR = ../glew-$(GLEW_VERSION) diff --git a/auto/Makefile b/auto/Makefile index 15f7cf7..d8d00f9 100644 --- a/auto/Makefile +++ b/auto/Makefile @@ -6,20 +6,25 @@ # General Public License Version 2 as published by the Free Software # Foundation or, at your option, any later version. -SHELL := bash -REGISTRY := registry -BIN := bin -SRC := src -CORE := core -EXT := extensions -BLACKLIST := blacklist +GLEW_MAJOR = 1 +GLEW_MINOR = 1 +GLEW_MICRO = 2 +GLEW_VERSION = $(GLEW_MAJOR).$(GLEW_MINOR).$(GLEW_MICRO) -PARSE_SPEC := parse_spec.pl +SHELL = bash +REGISTRY = registry +BIN = bin +SRC = src +CORE = core +EXT = extensions +BLACKLIST = blacklist -TOP := .. -I.DEST := $(TOP)/include/GL -S.DEST := $(TOP)/src -D.DEST := $(TOP)/doc +PARSE_SPEC = parse_spec.pl + +TOP = .. +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 @@ -84,6 +89,7 @@ $(S.DEST)/glew.c: $(EXT)/.dummy $(BIN)/make_list.pl $(EXT)/GLX_* >> $@ cat $(SRC)/glew_post.c >> $@ $(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 cp -f $(SRC)/glewinfo_pre.c $@ diff --git a/auto/src/glew_gl.c b/auto/src/glew_gl.c index 2c85386..441e930 100644 --- a/auto/src/glew_gl.c +++ b/auto/src/glew_gl.c @@ -32,7 +32,7 @@ static int _glewStrSame (const char *a, const char *b, int n) * other extension names. Could use strtok() but the constant * string returned by glGetString might be in read-only memory. */ -GLboolean glewGetExtension (const char *name) +GLboolean glewGetExtension (const GLubyte *name) { char *p, *end; int len = _glewStrLen(name); diff --git a/auto/src/glew_post.c b/auto/src/glew_post.c index 951577d..16eee3d 100644 --- a/auto/src/glew_post.c +++ b/auto/src/glew_post.c @@ -5,28 +5,38 @@ /* ------------------------------------------------------------------------ */ -const char* glewGetErrorString (GLuint error) +const GLubyte* glewGetErrorString (GLenum error) { - static const char* _glewErrorString[] = + static const GLubyte* _glewErrorString[] = { "no error", "missing GL version", - "missing {ARB,EXT}_extensions_string", "GL 1.1 and up are not supported", "GLX 1.2 and up are not supported", "unknown error" }; - if (error > 5) error = 5; + if (error > sizeof(_glewErrorString)) error = sizeof(_glewErrorString); 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; -GLuint glewInit () +GLenum glewInit () { - GLuint r; + GLenum r; if ( (r = _glewInit()) ) return r; #ifdef _WIN32 return _wglewInit(); diff --git a/auto/src/glew_post.h b/auto/src/glew_post.h index b01000d..4a070a6 100644 --- a/auto/src/glew_post.h +++ b/auto/src/glew_post.h @@ -2,16 +2,20 @@ /* error codes */ #define GLEW_OK 0 +#define GLEW_NO_ERROR 0 #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 3 /* GL 1.1 and up are not supported */ -#define GLEW_ERROR_GLX_VERSION_11_ONLY 4 /* GLX 1.2 and up are not supported */ +#define GLEW_ERROR_GL_VERSION_10_ONLY 2 /* GL 1.1 and up are not supported */ +#define GLEW_ERROR_GLX_VERSION_11_ONLY 3 /* GLX 1.2 and up are not supported */ + +/* string codes */ +#define GLEW_VERSION 1 /* API */ GLEWAPI GLboolean glewExperimental; -GLEWAPI GLuint glewInit (); -GLEWAPI GLboolean glewGetExtension (const char* name); -GLEWAPI const char* glewGetErrorString (GLuint error); +GLEWAPI GLenum glewInit (); +GLEWAPI GLboolean glewGetExtension (const GLubyte* name); +GLEWAPI const GLubyte* glewGetErrorString (GLenum error); +GLEWAPI const GLubyte* glewGetString (GLenum name); #ifdef __cplusplus } diff --git a/auto/src/glew_pre.c b/auto/src/glew_pre.c index 76d21d0..11f84e5 100644 --- a/auto/src/glew_pre.c +++ b/auto/src/glew_pre.c @@ -48,28 +48,21 @@ #include #include -static void * __dlopenGetProcAddress(const GLubyte *procName) +static void* __dlopenGetProcAddress (const GLubyte *procName) { - static void *h = NULL; - static void *gpa; + static void *h = NULL; + static void *gpa; - if (!h) - { - if (!(h = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL))) - { - fprintf(stderr, - "E: GLEW failed to dlopen myself: %s.\nAbort.\n", - dlerror()); - exit(100); - } + if (!h) + { + if (!(h = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL))) return NULL; + gpa = dlsym(h, "glXGetProcAddress"); + } - gpa = dlsym(h, "glXGetProcAddress"); - } - - if (gpa != NULL) - return ((void* (*)(const GLubyte*))gpa)(procName); - else - return dlsym(h, (const char *)procName); + if (gpa != NULL) + return ((void* (*)(const GLubyte*))gpa)(procName); + else + return dlsym(h, (const char *)procName); } #endif /* GLEW_NEEDS_CUSTOM_GET_PROCADDRESS */ diff --git a/auto/src/glew_wgl.c b/auto/src/glew_wgl.c index e63d91e..4fed911 100644 --- a/auto/src/glew_wgl.c +++ b/auto/src/glew_wgl.c @@ -34,6 +34,4 @@ static GLuint _wglewInit () WGLEW_ARB_extensions_string = wglGetExtensionsStringARB != NULL; _glewInit_WGL_EXT_extensions_string(); 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 */ diff --git a/auto/src/glewinfo_post.c b/auto/src/glewinfo_post.c index 0229181..07e8e6a 100644 --- a/auto/src/glewinfo_post.c +++ b/auto/src/glewinfo_post.c @@ -28,6 +28,7 @@ int main (int argc, char** argv) fprintf(f, "Running on a %s from %s\n", glGetString(GL_RENDERER), glGetString(GL_VENDOR)); fprintf(f, "OpenGL version %s is supported\n", glGetString(GL_VERSION)); + fprintf(f, "GLEW version %s is supported\n", glewGetString(GLEW_VERSION)); glewInfo(); #ifdef _WIN32 wglewInfo();