diff --git a/auto/src/glew_init_glx.c b/auto/src/glew_init_glx.c index d160249..b54cca3 100644 --- a/auto/src/glew_init_glx.c +++ b/auto/src/glew_init_glx.c @@ -12,7 +12,11 @@ GLboolean glxewGetExtension (const char* name) return _glewSearchExtension(name, start, end); } +#ifdef GLEW_MX GLenum glxewContextInit (GLXEW_CONTEXT_ARG_DEF_LIST) +#else +GLenum glxewInit (GLXEW_CONTEXT_ARG_DEF_LIST) +#endif { int major, minor; const GLubyte* extStart; diff --git a/auto/src/glew_init_tail.c b/auto/src/glew_init_tail.c index 7ae7217..cc3a34f 100644 --- a/auto/src/glew_init_tail.c +++ b/auto/src/glew_init_tail.c @@ -34,21 +34,15 @@ GLboolean glewExperimental = GL_FALSE; #if !defined(GLEW_MX) -#if defined(_WIN32) -extern GLenum GLEWAPIENTRY wglewContextInit (void); -#elif !defined(__ANDROID__) && !defined(__native_client__) && !defined(__HAIKU__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX)) -extern GLenum GLEWAPIENTRY glxewContextInit (void); -#endif /* _WIN32 */ - GLenum GLEWAPIENTRY glewInit (void) { GLenum r; r = glewContextInit(); if ( r != 0 ) return r; #if defined(_WIN32) - return wglewContextInit(); + return wglewInit(); #elif !defined(__ANDROID__) && !defined(__native_client__) && !defined(__HAIKU__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX)) /* _UNIX */ - return glxewContextInit(); + return glxewInit(); #else return r; #endif /* _WIN32 */ diff --git a/auto/src/glew_init_wgl.c b/auto/src/glew_init_wgl.c index 7e76099..cc731fe 100644 --- a/auto/src/glew_init_wgl.c +++ b/auto/src/glew_init_wgl.c @@ -20,7 +20,11 @@ GLboolean GLEWAPIENTRY wglewGetExtension (const char* name) return _glewSearchExtension(name, start, end); } +#ifdef GLEW_MX GLenum GLEWAPIENTRY wglewContextInit (WGLEW_CONTEXT_ARG_DEF_LIST) +#else +GLenum GLEWAPIENTRY wglewInit (WGLEW_CONTEXT_ARG_DEF_LIST) +#endif { GLboolean crippled; const GLubyte* extStart; diff --git a/auto/src/glewinfo_tail.c b/auto/src/glewinfo_tail.c index 8aed4d3..a5e9232 100644 --- a/auto/src/glewinfo_tail.c +++ b/auto/src/glewinfo_tail.c @@ -195,7 +195,7 @@ GLboolean glewCreateContext (struct createParams* params) int contextAttrs[20]; int i; - wglewContextInit(); + wglewInit(); /* Intel HD 3000 has WGL_ARB_create_context, but not WGL_ARB_create_context_profile */ if (!wglewGetExtension("WGL_ARB_create_context")) @@ -368,7 +368,7 @@ GLboolean glewCreateContext (struct createParams *params) int contextAttrs[20]; int nelems, i; - glxewContextInit(); + glxewInit(); if (!glxewGetExtension("GLX_ARB_create_context")) return GL_TRUE; diff --git a/auto/src/glxew_tail.h b/auto/src/glxew_tail.h index ddffffb..e086253 100644 --- a/auto/src/glxew_tail.h +++ b/auto/src/glxew_tail.h @@ -14,14 +14,12 @@ GLEWAPI GLboolean GLEWAPIENTRY glxewContextIsSupported (const GLXEWContext *ctx, #else /* GLEW_MX */ -GLEWAPI GLenum GLEWAPIENTRY glxewContextInit (); -GLEWAPI GLboolean GLEWAPIENTRY glxewContextIsSupported (const char *name); +GLEWAPI GLenum GLEWAPIENTRY glxewInit (); +GLEWAPI GLboolean GLEWAPIENTRY glxewIsSupported (const char *name); #define GLXEW_GET_VAR(x) (*(const GLboolean*)&x) #define GLXEW_GET_FUN(x) x -GLEWAPI GLboolean GLEWAPIENTRY glxewIsSupported (const char *name); - #endif /* GLEW_MX */ GLEWAPI GLboolean GLEWAPIENTRY glxewGetExtension (const char *name); diff --git a/auto/src/wglew_tail.h b/auto/src/wglew_tail.h index 0e38466..f48f36c 100644 --- a/auto/src/wglew_tail.h +++ b/auto/src/wglew_tail.h @@ -14,13 +14,12 @@ GLEWAPI GLboolean GLEWAPIENTRY wglewContextIsSupported (const WGLEWContext *ctx, #else /* GLEW_MX */ +GLEWAPI GLenum GLEWAPIENTRY wglewInit (); +GLEWAPI GLboolean GLEWAPIENTRY wglewIsSupported (const char *name); + #define WGLEW_GET_VAR(x) (*(const GLboolean*)&x) #define WGLEW_GET_FUN(x) x -GLEWAPI GLenum GLEWAPIENTRY wglewContextInit (); -GLEWAPI GLboolean GLEWAPIENTRY wglewContextIsSupported (const char *name); -GLEWAPI GLboolean GLEWAPIENTRY wglewIsSupported (const char *name); - #endif /* GLEW_MX */ GLEWAPI GLboolean GLEWAPIENTRY wglewGetExtension (const char *name); diff --git a/config/Makefile.darwin b/config/Makefile.darwin index 56fd584..8dd6262 100644 --- a/config/Makefile.darwin +++ b/config/Makefile.darwin @@ -9,7 +9,7 @@ ifneq (undefined, $(origin GLEW_APPLE_GLX)) CFLAGS.EXTRA += -I/usr/X11R6/include -D'GLEW_APPLE_GLX' LDFLAGS.GL = -L/usr/X11R6/lib -lGL -lX11 else -LDFLAGS.GL = -framework AGL -framework OpenGL +LDFLAGS.GL = -framework OpenGL endif LDFLAGS.STATIC = LDFLAGS.DYNAMIC = diff --git a/config/Makefile.darwin-ppc b/config/Makefile.darwin-ppc index 46c8b73..60ae3fd 100644 --- a/config/Makefile.darwin-ppc +++ b/config/Makefile.darwin-ppc @@ -8,7 +8,7 @@ ifneq (undefined, $(origin GLEW_APPLE_GLX)) CFLAGS.EXTRA += -I/usr/X11R6/include -D'GLEW_APPLE_GLX' LDFLAGS.GL = -L/usr/X11R6/lib -lGL -lX11 else -LDFLAGS.GL = -framework AGL -framework OpenGL +LDFLAGS.GL = -framework OpenGL endif LDFLAGS.STATIC = LDFLAGS.DYNAMIC = diff --git a/config/Makefile.darwin-universal b/config/Makefile.darwin-universal index 5f3f278..2b3156b 100644 --- a/config/Makefile.darwin-universal +++ b/config/Makefile.darwin-universal @@ -12,7 +12,7 @@ ifneq (undefined, $(origin GLEW_APPLE_GLX)) CFLAGS.EXTRA += -I/usr/X11R6/include -D'GLEW_APPLE_GLX' LDFLAGS.GL = -L/usr/X11R6/lib -lGL -lX11 else -LDFLAGS.GL = -framework AGL -framework OpenGL +LDFLAGS.GL = -framework OpenGL endif LDFLAGS.DYNAMIC = WARN = -Wall -W diff --git a/config/Makefile.darwin-x86_64 b/config/Makefile.darwin-x86_64 index e6eb050..5e8156b 100644 --- a/config/Makefile.darwin-x86_64 +++ b/config/Makefile.darwin-x86_64 @@ -8,7 +8,7 @@ ifneq (undefined, $(origin GLEW_APPLE_GLX)) CFLAGS.EXTRA += -I/usr/X11R6/include -D'GLEW_APPLE_GLX' LDFLAGS.GL = -L/usr/X11R6/lib -lGL -lX11 else -LDFLAGS.GL = -framework AGL -framework OpenGL +LDFLAGS.GL = -framework OpenGL endif LDFLAGS.STATIC = LDFLAGS.DYNAMIC = diff --git a/src/visualinfo.c b/src/visualinfo.c index 23a8499..fd27c7b 100644 --- a/src/visualinfo.c +++ b/src/visualinfo.c @@ -37,7 +37,8 @@ #if defined(_WIN32) #include #elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX) -#include +#include +#include #elif !defined(__HAIKU__) #include #endif @@ -61,7 +62,7 @@ typedef struct GLContextStruct HDC dc; HGLRC rc; #elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX) - AGLContext ctx, octx; + CGLContextObj ctx, octx; #elif !defined(__HAIKU__) Display* dpy; XVisualInfo* vi; @@ -1072,30 +1073,28 @@ void InitContext (GLContext* ctx) GLboolean CreateContext (GLContext* ctx) { - int attrib[] = { AGL_RGBA, AGL_NONE }; - AGLPixelFormat pf; + CGLPixelFormatAttribute attrib[] = { kCGLPFAAccelerated, 0 }; + CGLPixelFormatObj pf; + GLint npix; + CGLError error; /* check input */ if (NULL == ctx) return GL_TRUE; - /*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->ctx = aglCreateContext(pf, NULL); - if (NULL == ctx->ctx || AGL_NO_ERROR != aglGetError()) return GL_TRUE; - aglDestroyPixelFormat(pf); - /*aglSetDrawable(ctx, GetWindowPort(wnd));*/ - ctx->octx = aglGetCurrentContext(); - if (GL_FALSE == aglSetCurrentContext(ctx->ctx)) return GL_TRUE; + error = CGLChoosePixelFormat(attrib, &pf, &npix); + if (error) return GL_TRUE; + error = CGLCreateContext(pf, NULL, &ctx->ctx); + if (error) return GL_TRUE; + CGLReleasePixelFormat(pf); + ctx->octx = CGLGetCurrentContext(); + error = CGLSetCurrentContext(ctx->ctx); + if (error) return GL_TRUE; return GL_FALSE; } void DestroyContext (GLContext* ctx) { if (NULL == ctx) return; - aglSetCurrentContext(ctx->octx); - if (NULL != ctx->ctx) aglDestroyContext(ctx->ctx); + CGLSetCurrentContext(ctx->octx); + if (NULL != ctx->ctx) CGLReleaseContext(ctx->ctx); } /* ------------------------------------------------------------------------ */