I have the following code to create a shared rendering context (in order to use it in another thread) working perfectly on Linux (and also have the M$ version of that one too up and running…):
#ifdef __linux__
static Display *dpy = NULL;
static int scr = 0;
GLXContext GetCurrentContext( GLvoid )
{ return glXGetCurrentContext(); }
GLXContext CreateContext( GLXContext _ctx )
{
XVisualInfo *vi;
XVisualInfo tmp;
int nvis;
long mask;
dpy = glXGetCurrentDisplay();
scr = glXGetCurrentDrawable();
vi = XGetVisualInfo( dpy, mask, &tmp, &nvis );
return glXCreateContext( dpy, vi, _ctx, GL_TRUE );
}
GLvoid SetCurrentContext( GLXContext _ctx )
{ glXMakeCurrent( dpy, scr, _ctx ); }
GLvoid DestroyContext( GLXContext _ctx )
{ glXDestroyContext( dpy, _ctx ); }
#endif
Now I im trying to port that on MAC, I have to mention that Im using GLUT on MAC (and freeglut on Linux/M$) for portability convenience. Now I manage to produce this code:
#ifdef __APPLE__
AGLContext GetCurrentContext( GLvoid )
{ return aglGetCurrentContext(); }
AGLContext CreateContext( AGLContext _ctx )
{
GLint attribs[] =
{
AGL_RGBA,
AGL_ACCELERATED,
AGL_DOUBLEBUFFER,
AGL_DEPTH_SIZE, 24,
AGL_NONE
};
AGLPixelFormat pxf = aglChoosePixelFormat( NULL, 0, attribs );
return aglCreateContext( pxf, _ctx );
}
GLboolean SetCurrentContext( AGLContext _ctx )
{ return aglSetCurrentContext( _ctx ); }
GLvoid DestroyContext( AGLContext _ctx )
{ aglDestroyContext( _ctx ); }
#endif
Now… with the code above, I DO manage to create a AGLContext, however because of the pixel format my context don’t share lists, texture, vbos etc… (at least I guess that’s why.)
My question is:
#1. How can I manage to create a shared AGLContext even if Im using GLUT (cuz I got it up and running on other platforms)?
#2 . If #1 == “Yes”: How can I get the pixel format of another AGLContext, since AGL doesn’t provide no function whatsoever to get another pixel format?
Tks in advance,
Cheers!@