/**
- * Minimal __GLXContextRec that mimics a "real" GLX context.
+ * The GLXContext typedef is defined as a pointer to this structure.
*/
-typedef struct __GLXcontextRec
+struct __GLXcontextRec
{
Display *currentDpy;
GLboolean isDirect;
GLXDrawable currentDrawable;
GLXDrawable currentReadable;
XID xid;
-} __GLXcontext;
-
-/**
- * Our fake GLX context will contain a "real" GLX context and an XMesa context.
- *
- * Note that a pointer to a __GLXcontext is a pointer to a fake_glx_context,
- * and vice versa.
- *
- * XXX merge this struct with the one above.
- */
-struct fake_glx_context
-{
- __GLXcontext glxContext; /* this MUST be first! */
XMesaContext xmesaContext;
};
GLXContext share_list, Bool direct )
{
XMesaVisual xmvis;
- struct fake_glx_context *glxCtx;
- struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list;
+ GLXContext glxCtx;
+ GLXContext shareCtx = share_list;
if (!dpy || !visinfo)
return 0;
- glxCtx = CALLOC_STRUCT(fake_glx_context);
+ glxCtx = CALLOC_STRUCT(__GLXcontextRec);
if (!glxCtx)
return 0;
return NULL;
}
- glxCtx->glxContext.isDirect = DEFAULT_DIRECT;
- glxCtx->glxContext.currentDpy = dpy;
- glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */
-
- assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
+ glxCtx->isDirect = DEFAULT_DIRECT;
+ glxCtx->currentDpy = dpy;
+ glxCtx->xid = (XID) glxCtx; /* self pointer */
- return (GLXContext) glxCtx;
+ return glxCtx;
}
glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
GLXDrawable read, GLXContext ctx )
{
- struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
+ GLXContext glxCtx = ctx;
static boolean firsttime = 1, no_rast = 0;
if (firsttime) {
/* Now make current! */
if (XMesaMakeCurrent2(xmctx, drawBuffer, readBuffer)) {
- ((__GLXcontext *) ctx)->currentDpy = dpy;
- ((__GLXcontext *) ctx)->currentDrawable = draw;
- ((__GLXcontext *) ctx)->currentReadable = read;
+ ctx->currentDpy = dpy;
+ ctx->currentDrawable = draw;
+ ctx->currentReadable = read;
SetCurrentContext(ctx);
return True;
}
Display *
glXGetCurrentDisplay(void)
{
- struct fake_glx_context *glxCtx =
- (struct fake_glx_context *) glXGetCurrentContext();
+ GLXContext glxCtx = glXGetCurrentContext();
- return glxCtx ? glxCtx->glxContext.currentDpy : NULL;
+ return glxCtx ? glxCtx->currentDpy : NULL;
}
GLXDrawable
glXGetCurrentDrawable(void)
{
- __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
+ GLXContext gc = glXGetCurrentContext();
return gc ? gc->currentDrawable : 0;
}
GLXDrawable
glXGetCurrentReadDrawable(void)
{
- __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
+ GLXContext gc = glXGetCurrentContext();
return gc ? gc->currentReadable : 0;
}
glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
unsigned long mask )
{
- struct fake_glx_context *fakeSrc = (struct fake_glx_context *) src;
- struct fake_glx_context *fakeDst = (struct fake_glx_context *) dst;
+ GLXContext fakeSrc = src;
+ GLXContext fakeDst = dst;
XMesaContext xm_src = fakeSrc->xmesaContext;
XMesaContext xm_dst = fakeDst->xmesaContext;
(void) dpy;
void
glXDestroyContext( Display *dpy, GLXContext ctx )
{
- struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
+ GLXContext glxCtx = ctx;
(void) dpy;
MakeCurrent_PrevContext = 0;
MakeCurrent_PrevDrawable = 0;
Bool
glXIsDirect( Display *dpy, GLXContext ctx )
{
- struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
+ GLXContext glxCtx = ctx;
(void) ctx;
- return glxCtx->glxContext.isDirect;
+ return glxCtx->isDirect;
}
glXCreateNewContext( Display *dpy, GLXFBConfig config,
int renderType, GLXContext shareList, Bool direct )
{
- struct fake_glx_context *glxCtx;
- struct fake_glx_context *shareCtx = (struct fake_glx_context *) shareList;
+ GLXContext glxCtx;
+ GLXContext shareCtx = shareList;
XMesaVisual xmvis = (XMesaVisual) config;
if (!dpy || !config ||
(renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE))
return 0;
- glxCtx = CALLOC_STRUCT(fake_glx_context);
+ glxCtx = CALLOC_STRUCT(__GLXcontextRec);
if (!glxCtx)
return 0;
return NULL;
}
- glxCtx->glxContext.isDirect = DEFAULT_DIRECT;
- glxCtx->glxContext.currentDpy = dpy;
- glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */
+ glxCtx->isDirect = DEFAULT_DIRECT;
+ glxCtx->currentDpy = dpy;
+ glxCtx->xid = (XID) glxCtx; /* self pointer */
- assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
-
- return (GLXContext) glxCtx;
+ return glxCtx;
}
int
glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value )
{
- struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
+ GLXContext glxCtx = ctx;
XMesaContext xmctx = glxCtx->xmesaContext;
(void) dpy;
glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
{
XMesaVisual xmvis = (XMesaVisual) config;
- struct fake_glx_context *glxCtx;
- struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list;
+ GLXContext glxCtx;
+ GLXContext shareCtx = share_list;
- glxCtx = CALLOC_STRUCT(fake_glx_context);
+ glxCtx = CALLOC_STRUCT(__GLXcontextRec);
if (!glxCtx)
return 0;
return NULL;
}
- glxCtx->glxContext.isDirect = DEFAULT_DIRECT;
- glxCtx->glxContext.currentDpy = dpy;
- glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */
-
- assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
+ glxCtx->isDirect = DEFAULT_DIRECT;
+ glxCtx->currentDpy = dpy;
+ glxCtx->xid = (XID) glxCtx; /* self pointer */
- return (GLXContext) glxCtx;
+ return glxCtx;
}