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
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

View File

@ -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 */
}

View File

@ -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 <AGL/agl.h>
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) */
/* ------------------------------------------------------------------------ */