No longer using deprecated AGL framework on Mac for visualinfo

This commit is contained in:
Nigel Stewart 2015-08-07 12:23:36 +10:00
parent e1815b2729
commit 54b537afda
5 changed files with 21 additions and 22 deletions

View File

@ -9,7 +9,7 @@ ifneq (undefined, $(origin GLEW_APPLE_GLX))
CFLAGS.EXTRA += -I/usr/X11R6/include -D'GLEW_APPLE_GLX' CFLAGS.EXTRA += -I/usr/X11R6/include -D'GLEW_APPLE_GLX'
LDFLAGS.GL = -L/usr/X11R6/lib -lGL -lX11 LDFLAGS.GL = -L/usr/X11R6/lib -lGL -lX11
else else
LDFLAGS.GL = -framework AGL -framework OpenGL LDFLAGS.GL = -framework OpenGL
endif endif
LDFLAGS.STATIC = LDFLAGS.STATIC =
LDFLAGS.DYNAMIC = LDFLAGS.DYNAMIC =

View File

@ -8,7 +8,7 @@ ifneq (undefined, $(origin GLEW_APPLE_GLX))
CFLAGS.EXTRA += -I/usr/X11R6/include -D'GLEW_APPLE_GLX' CFLAGS.EXTRA += -I/usr/X11R6/include -D'GLEW_APPLE_GLX'
LDFLAGS.GL = -L/usr/X11R6/lib -lGL -lX11 LDFLAGS.GL = -L/usr/X11R6/lib -lGL -lX11
else else
LDFLAGS.GL = -framework AGL -framework OpenGL LDFLAGS.GL = -framework OpenGL
endif endif
LDFLAGS.STATIC = LDFLAGS.STATIC =
LDFLAGS.DYNAMIC = LDFLAGS.DYNAMIC =

View File

@ -12,7 +12,7 @@ ifneq (undefined, $(origin GLEW_APPLE_GLX))
CFLAGS.EXTRA += -I/usr/X11R6/include -D'GLEW_APPLE_GLX' CFLAGS.EXTRA += -I/usr/X11R6/include -D'GLEW_APPLE_GLX'
LDFLAGS.GL = -L/usr/X11R6/lib -lGL -lX11 LDFLAGS.GL = -L/usr/X11R6/lib -lGL -lX11
else else
LDFLAGS.GL = -framework AGL -framework OpenGL LDFLAGS.GL = -framework OpenGL
endif endif
LDFLAGS.DYNAMIC = LDFLAGS.DYNAMIC =
WARN = -Wall -W WARN = -Wall -W

View File

@ -8,7 +8,7 @@ ifneq (undefined, $(origin GLEW_APPLE_GLX))
CFLAGS.EXTRA += -I/usr/X11R6/include -D'GLEW_APPLE_GLX' CFLAGS.EXTRA += -I/usr/X11R6/include -D'GLEW_APPLE_GLX'
LDFLAGS.GL = -L/usr/X11R6/lib -lGL -lX11 LDFLAGS.GL = -L/usr/X11R6/lib -lGL -lX11
else else
LDFLAGS.GL = -framework AGL -framework OpenGL LDFLAGS.GL = -framework OpenGL
endif endif
LDFLAGS.STATIC = LDFLAGS.STATIC =
LDFLAGS.DYNAMIC = LDFLAGS.DYNAMIC =

View File

@ -37,7 +37,8 @@
#if defined(_WIN32) #if defined(_WIN32)
#include <GL/wglew.h> #include <GL/wglew.h>
#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX) #elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)
#include <AGL/agl.h> #include <OpenGL/OpenGL.h>
#include <OpenGL/CGLTypes.h>
#elif !defined(__HAIKU__) #elif !defined(__HAIKU__)
#include <GL/glxew.h> #include <GL/glxew.h>
#endif #endif
@ -61,7 +62,7 @@ typedef struct GLContextStruct
HDC dc; HDC dc;
HGLRC rc; HGLRC rc;
#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX) #elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)
AGLContext ctx, octx; CGLContextObj ctx, octx;
#elif !defined(__HAIKU__) #elif !defined(__HAIKU__)
Display* dpy; Display* dpy;
XVisualInfo* vi; XVisualInfo* vi;
@ -1072,30 +1073,28 @@ void InitContext (GLContext* ctx)
GLboolean CreateContext (GLContext* ctx) GLboolean CreateContext (GLContext* ctx)
{ {
int attrib[] = { AGL_RGBA, AGL_NONE }; CGLPixelFormatAttribute attrib[] = { kCGLPFAAccelerated, 0 };
AGLPixelFormat pf; CGLPixelFormatObj pf;
GLint npix;
CGLError error;
/* check input */ /* check input */
if (NULL == ctx) return GL_TRUE; if (NULL == ctx) return GL_TRUE;
/*int major, minor; error = CGLChoosePixelFormat(attrib, &pf, &npix);
SetPortWindowPort(wnd); if (error) return GL_TRUE;
aglGetVersion(&major, &minor); error = CGLCreateContext(pf, NULL, &ctx->ctx);
fprintf(stderr, "GL %d.%d\n", major, minor);*/ if (error) return GL_TRUE;
pf = aglChoosePixelFormat(NULL, 0, attrib); CGLReleasePixelFormat(pf);
if (NULL == pf) return GL_TRUE; ctx->octx = CGLGetCurrentContext();
ctx->ctx = aglCreateContext(pf, NULL); error = CGLSetCurrentContext(ctx->ctx);
if (NULL == ctx->ctx || AGL_NO_ERROR != aglGetError()) return GL_TRUE; if (error) return GL_TRUE;
aglDestroyPixelFormat(pf);
/*aglSetDrawable(ctx, GetWindowPort(wnd));*/
ctx->octx = aglGetCurrentContext();
if (GL_FALSE == aglSetCurrentContext(ctx->ctx)) return GL_TRUE;
return GL_FALSE; return GL_FALSE;
} }
void DestroyContext (GLContext* ctx) void DestroyContext (GLContext* ctx)
{ {
if (NULL == ctx) return; if (NULL == ctx) return;
aglSetCurrentContext(ctx->octx); CGLSetCurrentContext(ctx->octx);
if (NULL != ctx->ctx) aglDestroyContext(ctx->ctx); if (NULL != ctx->ctx) CGLReleaseContext(ctx->ctx);
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */