diff --git a/Makefile b/Makefile index 088898f..ea3bb71 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,7 @@ TARBALL = ../glew_$(GLEW_VERSION).tar.gz SHELL = /bin/sh SYSTEM = $(strip $(shell uname -s)) + # ---------------------------------------------------------------------------- # Cygwin # ---------------------------------------------------------------------------- @@ -115,7 +116,12 @@ LD = cc CFLAGS.EXTRA = -dynamic -I/usr/X11R6/include LDFLAGS.SO = -dynamiclib LDFLAGS.EXTRA = -L/usr/X11R6/lib +ifdef GLEW_APPLE_GLX +CFLAGS.EXTRA += -D'GLEW_APPLE_GLX' LDFLAGS.GL = -lXmu -lXi -lGLU -lGL -lXext -lX11 +else +LDFLAGS.GL = -framework AGL -lGL +endif NAME = GLEW BIN.SUFFIX = WARN = -Wall -W diff --git a/auto/src/glew_post.c b/auto/src/glew_post.c index 0f35a95..6f0d5aa 100644 --- a/auto/src/glew_post.c +++ b/auto/src/glew_post.c @@ -38,9 +38,11 @@ GLenum glewInit () { GLenum r; if ( (r = _glewInit()) ) return r; -#ifdef _WIN32 +#if defined(_WIN32) return _wglewInit(); -#else /* _UNIX */ +#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) /* _UNIX */ return _glxewInit(); +#else + return r; #endif /* _WIN32 */ } diff --git a/auto/src/glewinfo_post.c b/auto/src/glewinfo_post.c index 907e231..e90e6ff 100644 --- a/auto/src/glewinfo_post.c +++ b/auto/src/glewinfo_post.c @@ -99,51 +99,38 @@ void glewDestroyContext () /* ------------------------------------------------------------------------ */ -# ifdef __APPLE__ +# if defined(__APPLE__) && !defined(GLEW_APPLE_GLX) -Display* dpy = NULL; -XVisualInfo* vi = NULL; -GLXContext ctx = NULL; -Window wnd; -Colormap cmap; +#include + +AGLContext ctx, octx; GLboolean glewCreateContext () { - int attrib[] = { GLX_RGBA, None }; - int erb, evb; - XSetWindowAttributes swa; - /* open display */ - dpy = XOpenDisplay(NULL); - if (NULL == dpy) return GL_TRUE; - /* query for glx */ - if (!glXQueryExtension(dpy, &erb, &evb)) return GL_TRUE; - /* choose visual */ - vi = glXChooseVisual(dpy, DefaultScreen(dpy), attrib); - if (NULL == vi) return GL_TRUE; - /* create context */ - ctx = glXCreateContext(dpy, vi, None, True); - if (NULL == ctx) return GL_TRUE; - /* create window */ - /*wnd = XCreateSimpleWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 1, 1, 1, 0, 0);*/ - cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone); - swa.border_pixel = 0; - swa.colormap = cmap; - wnd = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 256, 256, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap, &swa); - /* make context current */ - if (!glXMakeCurrent(dpy, wnd, ctx)) return GL_TRUE; + int attrib[] = { AGL_RGBA, AGL_NONE }; + AGLPixelFormat pf; + //int major, minor; + //SetPortWindowPort(wnd); + //aglGetVersion(&major, &minor); + //fprintf(stderr, "GL %d.%d\n", major, minor); + pf = aglChoosePixelFormat(NULL, 0, attrib); + if (NULL == pf) return GL_TRUE; + ctx = aglCreateContext(pf, NULL); + if (NULL == ctx || AGL_NO_ERROR != aglGetError()) return GL_TRUE; + aglDestroyPixelFormat(pf); + //aglSetDrawable(ctx, GetWindowPort(wnd)); + octx = aglGetCurrentContext(); + if (NULL == aglSetCurrentContext(ctx)) return GL_TRUE; return GL_FALSE; } void glewDestroyContext () { - if (NULL != dpy && NULL != ctx) glXDestroyContext(dpy, ctx); - if (NULL != dpy) XDestroyWindow(dpy, wnd); - if (NULL != dpy) XFreeColormap(dpy, cmap); - if (NULL != vi) XFree(vi); - if (NULL != dpy) XCloseDisplay(dpy); + aglSetCurrentContext(octx); + if (NULL != ctx) aglDestroyContext(ctx); } -# else /* __linux || __sgi */ +# else /* __linux || __sgi || (__APPLE__ && GLEW_APPLE_GLX) */ /* ------------------------------------------------------------------------ */