mirror of
https://github.com/nigels-com/glew.git
synced 2024-11-28 08:41:55 +00:00
[CoreSupport] Migrate glewinfo on Mac from AGL to CGL, with the possibility of running in (core) OpenGL 3.2 mode.
This commit is contained in:
parent
e02cac5b3b
commit
9a5a4cdaed
@ -185,26 +185,34 @@ void glewDestroyContext ()
|
|||||||
|
|
||||||
#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>
|
||||||
|
|
||||||
AGLContext ctx, octx;
|
CGLContextObj ctx, octx;
|
||||||
|
|
||||||
GLboolean glewCreateContext ()
|
GLboolean glewCreateContext ()
|
||||||
{
|
{
|
||||||
int attrib[] = { AGL_RGBA, AGL_NONE };
|
const CGLPixelFormatAttribute attrib[4] =
|
||||||
AGLPixelFormat pf;
|
{
|
||||||
/*int major, minor;
|
kCGLPFAAccelerated, /* No software rendering */
|
||||||
SetPortWindowPort(wnd);
|
#if 0
|
||||||
aglGetVersion(&major, &minor);
|
kCGLPFAOpenGLProfile, /* OSX 10.7 Lion onwards */
|
||||||
fprintf(stderr, "GL %d.%d\n", major, minor);*/
|
(CGLPixelFormatAttribute) kCGLOGLPVersion_3_2_Core, /* 3.2 Core Context */
|
||||||
pf = aglChoosePixelFormat(NULL, 0, attrib);
|
#endif
|
||||||
if (NULL == pf) return GL_TRUE;
|
0
|
||||||
ctx = aglCreateContext(pf, NULL);
|
};
|
||||||
if (NULL == ctx || AGL_NO_ERROR != aglGetError()) return GL_TRUE;
|
CGLPixelFormatObj pf;
|
||||||
aglDestroyPixelFormat(pf);
|
GLint npix;
|
||||||
/*aglSetDrawable(ctx, GetWindowPort(wnd));*/
|
CGLError error;
|
||||||
octx = aglGetCurrentContext();
|
|
||||||
if (GL_FALSE == aglSetCurrentContext(ctx)) return GL_TRUE;
|
error = CGLChoosePixelFormat(attrib, &pf, &npix);
|
||||||
|
if (error) return GL_TRUE;
|
||||||
|
error = CGLCreateContext(pf, NULL, &ctx);
|
||||||
|
if (error) return GL_TRUE;
|
||||||
|
CGLReleasePixelFormat(pf);
|
||||||
|
octx = CGLGetCurrentContext();
|
||||||
|
error = CGLSetCurrentContext(ctx);
|
||||||
|
if (error) return GL_TRUE;
|
||||||
/* Needed for Regal on the Mac */
|
/* Needed for Regal on the Mac */
|
||||||
#if defined(GLEW_REGAL) && defined(__APPLE__)
|
#if defined(GLEW_REGAL) && defined(__APPLE__)
|
||||||
RegalMakeCurrent(ctx);
|
RegalMakeCurrent(ctx);
|
||||||
@ -214,8 +222,8 @@ GLboolean glewCreateContext ()
|
|||||||
|
|
||||||
void glewDestroyContext ()
|
void glewDestroyContext ()
|
||||||
{
|
{
|
||||||
aglSetCurrentContext(octx);
|
CGLSetCurrentContext(octx);
|
||||||
if (NULL != ctx) aglDestroyContext(ctx);
|
CGLReleaseContext(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
Loading…
Reference in New Issue
Block a user