extended Darwin support

git-svn-id: https://glew.svn.sourceforge.net/svnroot/glew/trunk/glew@150 783a27ee-832a-0410-bc00-9f386506c6dd
This commit is contained in:
ikits 2003-10-27 01:06:34 +00:00
parent 05d6b91c55
commit 9211cee4e0
3 changed files with 31 additions and 36 deletions

View File

@ -41,6 +41,7 @@ TARBALL = ../glew_$(GLEW_VERSION).tar.gz
SHELL = /bin/sh SHELL = /bin/sh
SYSTEM = $(strip $(shell uname -s)) SYSTEM = $(strip $(shell uname -s))
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Cygwin # Cygwin
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
@ -115,7 +116,12 @@ LD = cc
CFLAGS.EXTRA = -dynamic -I/usr/X11R6/include CFLAGS.EXTRA = -dynamic -I/usr/X11R6/include
LDFLAGS.SO = -dynamiclib LDFLAGS.SO = -dynamiclib
LDFLAGS.EXTRA = -L/usr/X11R6/lib LDFLAGS.EXTRA = -L/usr/X11R6/lib
ifdef GLEW_APPLE_GLX
CFLAGS.EXTRA += -D'GLEW_APPLE_GLX'
LDFLAGS.GL = -lXmu -lXi -lGLU -lGL -lXext -lX11 LDFLAGS.GL = -lXmu -lXi -lGLU -lGL -lXext -lX11
else
LDFLAGS.GL = -framework AGL -lGL
endif
NAME = GLEW NAME = GLEW
BIN.SUFFIX = BIN.SUFFIX =
WARN = -Wall -W WARN = -Wall -W

View File

@ -38,9 +38,11 @@ GLenum glewInit ()
{ {
GLenum r; GLenum r;
if ( (r = _glewInit()) ) return r; if ( (r = _glewInit()) ) return r;
#ifdef _WIN32 #if defined(_WIN32)
return _wglewInit(); return _wglewInit();
#else /* _UNIX */ #elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) /* _UNIX */
return _glxewInit(); return _glxewInit();
#else
return r;
#endif /* _WIN32 */ #endif /* _WIN32 */
} }

View File

@ -99,51 +99,38 @@ void glewDestroyContext ()
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
# ifdef __APPLE__ # if defined(__APPLE__) && !defined(GLEW_APPLE_GLX)
Display* dpy = NULL; #include <AGL/agl.h>
XVisualInfo* vi = NULL;
GLXContext ctx = NULL; AGLContext ctx, octx;
Window wnd;
Colormap cmap;
GLboolean glewCreateContext () GLboolean glewCreateContext ()
{ {
int attrib[] = { GLX_RGBA, None }; int attrib[] = { AGL_RGBA, AGL_NONE };
int erb, evb; AGLPixelFormat pf;
XSetWindowAttributes swa; //int major, minor;
/* open display */ //SetPortWindowPort(wnd);
dpy = XOpenDisplay(NULL); //aglGetVersion(&major, &minor);
if (NULL == dpy) return GL_TRUE; //fprintf(stderr, "GL %d.%d\n", major, minor);
/* query for glx */ pf = aglChoosePixelFormat(NULL, 0, attrib);
if (!glXQueryExtension(dpy, &erb, &evb)) return GL_TRUE; if (NULL == pf) return GL_TRUE;
/* choose visual */ ctx = aglCreateContext(pf, NULL);
vi = glXChooseVisual(dpy, DefaultScreen(dpy), attrib); if (NULL == ctx || AGL_NO_ERROR != aglGetError()) return GL_TRUE;
if (NULL == vi) return GL_TRUE; aglDestroyPixelFormat(pf);
/* create context */ //aglSetDrawable(ctx, GetWindowPort(wnd));
ctx = glXCreateContext(dpy, vi, None, True); octx = aglGetCurrentContext();
if (NULL == ctx) return GL_TRUE; if (NULL == aglSetCurrentContext(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;
return GL_FALSE; return GL_FALSE;
} }
void glewDestroyContext () void glewDestroyContext ()
{ {
if (NULL != dpy && NULL != ctx) glXDestroyContext(dpy, ctx); aglSetCurrentContext(octx);
if (NULL != dpy) XDestroyWindow(dpy, wnd); if (NULL != ctx) aglDestroyContext(ctx);
if (NULL != dpy) XFreeColormap(dpy, cmap);
if (NULL != vi) XFree(vi);
if (NULL != dpy) XCloseDisplay(dpy);
} }
# else /* __linux || __sgi */ # else /* __linux || __sgi || (__APPLE__ && GLEW_APPLE_GLX) */
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */