-/* $Id: fakeglx.c,v 1.43 2001/01/08 04:06:20 keithw Exp $ */
+/* $Id: fakeglx.c,v 1.44 2001/01/08 04:55:22 keithw Exp $ */
/*
* Mesa 3-D graphics library
GLXContext share_list, Bool direct )
{
XMesaVisual glxvis;
- struct __GLcontextRec *ctx;
+ XMesaContext xmctx;
/* deallocate unused windows/buffers */
XMesaGarbageCollect();
}
}
- ctx = XMesaCreateContext( glxvis, (struct __GLcontextRec *) share_list );
- if (ctx) {
- XMesaContext xmctx = (XMesaContext)(ctx->DriverCtx);
+ xmctx = XMesaCreateContext( glxvis, (XMesaContext) share_list );
+ if (xmctx) {
/* set the direct/indirect flag */
xmctx->direct = direct;
}
- return (GLXContext) ctx;
+ return (GLXContext) xmctx;
}
/* GLX 1.3 and later */
static Bool
Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
- GLXDrawable read, GLXContext glxctx )
+ GLXDrawable read, GLXContext ctx )
{
- if (glxctx && draw && read) {
+ if (ctx && draw && read) {
XMesaBuffer drawBuffer, readBuffer;
- GLcontext *ctx = (GLcontext *) glxctx;
- XMesaContext xmctx = (XMesaContext)(ctx->DriverCtx);
+ XMesaContext xmctx = (XMesaContext) ctx;
/* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
- if (glxctx == MakeCurrent_PrevContext &&
- draw == MakeCurrent_PrevDrawable) {
+ if (ctx == MakeCurrent_PrevContext
+ && draw == MakeCurrent_PrevDrawable) {
drawBuffer = MakeCurrent_PrevDrawBuffer;
}
else {
}
if (!drawBuffer) {
/* drawable must be a new window! */
- drawBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, draw, xmctx );
+ drawBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, draw, (XMesaContext) ctx );
if (!drawBuffer) {
/* Out of memory, or context/drawable depth mismatch */
return False;
}
/* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
- if (glxctx == MakeCurrent_PrevContext
+ if (ctx == MakeCurrent_PrevContext
&& read == MakeCurrent_PrevReadable) {
readBuffer = MakeCurrent_PrevReadBuffer;
}
}
if (!readBuffer) {
/* drawable must be a new window! */
- readBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, read, xmctx );
+ readBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, read, (XMesaContext) ctx );
if (!readBuffer) {
/* Out of memory, or context/drawable depth mismatch */
return False;
}
}
- MakeCurrent_PrevContext = glxctx;
+ MakeCurrent_PrevContext = ctx;
MakeCurrent_PrevDrawable = draw;
MakeCurrent_PrevReadable = read;
MakeCurrent_PrevDrawBuffer = drawBuffer;
MakeCurrent_PrevReadBuffer = readBuffer;
/* Now make current! */
- return (Bool) XMesaMakeCurrent2(xmctx, drawBuffer, readBuffer);
+ return (Bool) XMesaMakeCurrent2((XMesaContext) ctx, drawBuffer, readBuffer);
}
- else if (!glxctx && !draw && !read) {
+ else if (!ctx && !draw && !read) {
/* release current context w/out assigning new one. */
XMesaMakeCurrent( NULL, NULL );
MakeCurrent_PrevContext = 0;
Fake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
unsigned long mask )
{
- struct __GLcontextRec *csrc = (struct __GLcontextRec *) src;
- struct __GLcontextRec *cdst = (struct __GLcontextRec *) dst;
+ XMesaContext xm_src = (XMesaContext) src;
+ XMesaContext xm_dst = (XMesaContext) dst;
(void) dpy;
- _mesa_copy_context( csrc, cdst, (GLuint) mask );
+ _mesa_copy_context( xm_src->gl_ctx, xm_dst->gl_ctx, (GLuint) mask );
}
static void
Fake_glXDestroyContext( Display *dpy, GLXContext ctx )
{
- XMesaContext xmctx = (XMesaContext)(((GLcontext *)ctx)->DriverCtx);
(void) dpy;
MakeCurrent_PrevContext = 0;
MakeCurrent_PrevDrawable = 0;
MakeCurrent_PrevReadable = 0;
MakeCurrent_PrevDrawBuffer = 0;
MakeCurrent_PrevReadBuffer = 0;
- XMesaDestroyContext( xmctx );
+ XMesaDestroyContext( (XMesaContext) ctx );
XMesaGarbageCollect();
}
static Bool
Fake_glXIsDirect( Display *dpy, GLXContext ctx )
{
- XMesaContext xmctx = (XMesaContext)(((GLcontext *)ctx)->DriverCtx);
(void) dpy;
- return xmctx->direct;
+ return ((XMesaContext) ctx)->direct;
}
-/* $Id: xm_api.c,v 1.14 2001/01/08 04:06:20 keithw Exp $ */
+/* $Id: xm_api.c,v 1.15 2001/01/08 04:55:22 keithw Exp $ */
/*
* Mesa 3-D graphics library
* lists or NULL if no sharing is wanted.
* Return: an XMesaContext or NULL if error.
*/
-struct __GLcontextRec *XMesaCreateContext( XMesaVisual v,
- struct __GLcontextRec *share_list )
+XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
{
XMesaContext c;
GLcontext *ctx;
}
ctx = c->gl_ctx = _mesa_create_context( v->gl_visual,
- share_list,
- (void *) c,
- direct );
+ share_list ? share_list->gl_ctx : (GLcontext *) NULL,
+ (void *) c, direct );
if (!c->gl_ctx) {
FREE(c);
return NULL;
*/
_mesa_context_initialize( ctx );
- return ctx;
+
+ return c;
}
assert(v);
#ifdef XFree86Server
- if (GET_VISUAL_DEPTH(v) != ((XMesaDrawable)w)->depth)
+ if (GET_VISUAL_DEPTH(v) != ((XMesaDrawable)w)->depth) {
#else
- XGetWindowAttributes( v->display, w, &attr );
- if (GET_VISUAL_DEPTH(v) != attr.depth)
+ XGetWindowAttributes( v->display, w, &attr );
+
+ if (GET_VISUAL_DEPTH(v) != attr.depth) {
#endif
- {
if (getenv("MESA_DEBUG")) {
fprintf(stderr, "XMesaCreateWindowBuffer: depth mismatch between visual and window!\n");
}
#ifdef FX
fxEnvVar = getenv("MESA_GLX_FX");
if (fxEnvVar) {
- if (fxEnvVar[0]!='d') {
- int attribs[100];
- int numAttribs = 0;
- int hw;
- if (v->gl_visual->DepthBits > 0) {
- attribs[numAttribs++] = FXMESA_DEPTH_SIZE;
- attribs[numAttribs++] = 1;
- }
- if (v->gl_visual->DBflag) {
- attribs[numAttribs++] = FXMESA_DOUBLEBUFFER;
- }
- if (v->gl_visual->AccumRedBits > 0) {
- attribs[numAttribs++] = FXMESA_ACCUM_SIZE;
- attribs[numAttribs++] = v->gl_visual->AccumRedBits;
- }
- if (v->gl_visual->StencilBits > 0) {
- attribs[numAttribs++] = FXMESA_STENCIL_SIZE;
- attribs[numAttribs++] = v->gl_visual->StencilBits;
- }
- if (v->gl_visual->AlphaBits > 0) {
- attribs[numAttribs++] = FXMESA_ALPHA_SIZE;
- attribs[numAttribs++] = 1;
- }
- if (c->gl_ctx) {
+ if (fxEnvVar[0]!='d') {
+ int attribs[100];
+ int numAttribs = 0;
+ int hw;
+ if (v->gl_visual->DepthBits > 0) {
+ attribs[numAttribs++] = FXMESA_DEPTH_SIZE;
+ attribs[numAttribs++] = 1;
+ }
+ if (v->gl_visual->DBflag) {
+ attribs[numAttribs++] = FXMESA_DOUBLEBUFFER;
+ }
+ if (v->gl_visual->AccumRedBits > 0) {
+ attribs[numAttribs++] = FXMESA_ACCUM_SIZE;
+ attribs[numAttribs++] = v->gl_visual->AccumRedBits;
+ }
+ if (v->gl_visual->StencilBits > 0) {
+ attribs[numAttribs++] = FXMESA_STENCIL_SIZE;
+ attribs[numAttribs++] = v->gl_visual->StencilBits;
+ }
+ if (v->gl_visual->AlphaBits > 0) {
+ attribs[numAttribs++] = FXMESA_ALPHA_SIZE;
+ attribs[numAttribs++] = 1;
+ }
+ if (c->gl_ctx) {
#define FXMESA_SHARE_CONTEXT 990099 /* keep in sync with fxapi.c! */
- attribs[numAttribs++] = FXMESA_SHARE_CONTEXT;
- attribs[numAttribs++] = (int) c->gl_ctx;
- }
- attribs[numAttribs++] = FXMESA_NONE;
-
- if ((hw = fxQueryHardware())==GR_SSTTYPE_VOODOO) {
- b->FXctx = fxMesaCreateBestContext(0, b->width, b->height, attribs);
- if ((v->undithered_pf!=PF_INDEX) && (b->backimage)) {
- b->FXisHackUsable = b->FXctx ? GL_TRUE : GL_FALSE;
- if (fxEnvVar[0]=='w' || fxEnvVar[0]=='W')
- b->FXwindowHack = b->FXctx ? GL_TRUE : GL_FALSE;
- else
- b->FXwindowHack = GL_FALSE;
- }
- }
- else {
- if (fxEnvVar[0]=='w' || fxEnvVar[0]=='W')
- b->FXctx = fxMesaCreateContext(w, GR_RESOLUTION_NONE,
- GR_REFRESH_75Hz, attribs);
- else
- b->FXctx = fxMesaCreateBestContext(0, b->width, b->height, attribs);
- b->FXisHackUsable = GL_FALSE;
- b->FXwindowHack = GL_FALSE;
- }
- /*
- fprintf(stderr,
- "voodoo %d, wid %d height %d hack: usable %d active %d\n",
- hw, b->width, b->height, b->FXisHackUsable, b->FXwindowHack);
- */
- }
+ attribs[numAttribs++] = FXMESA_SHARE_CONTEXT;
+ attribs[numAttribs++] = (int) c->gl_ctx;
+ }
+ attribs[numAttribs++] = FXMESA_NONE;
+
+ if ((hw = fxQueryHardware())==GR_SSTTYPE_VOODOO) {
+ b->FXctx = fxMesaCreateBestContext(0, b->width, b->height, attribs);
+ if ((v->undithered_pf!=PF_INDEX) && (b->backimage)) {
+ b->FXisHackUsable = b->FXctx ? GL_TRUE : GL_FALSE;
+ if (fxEnvVar[0]=='w' || fxEnvVar[0]=='W')
+ b->FXwindowHack = b->FXctx ? GL_TRUE : GL_FALSE;
+ else
+ b->FXwindowHack = GL_FALSE;
+ }
+ }
+ else {
+ if (fxEnvVar[0]=='w' || fxEnvVar[0]=='W')
+ b->FXctx = fxMesaCreateContext(w, GR_RESOLUTION_NONE,
+ GR_REFRESH_75Hz, attribs);
+ else
+ b->FXctx = fxMesaCreateBestContext(0, b->width, b->height, attribs);
+ b->FXisHackUsable = GL_FALSE;
+ b->FXwindowHack = GL_FALSE;
+ }
+ /*
+ fprintf(stderr,
+ "voodoo %d, wid %d height %d hack: usable %d active %d\n",
+ hw, b->width, b->height, b->FXisHackUsable, b->FXwindowHack);
+ */
+ }
}
else {
fprintf(stderr,"WARNING: This Mesa Library includes the Glide driver but\n");