diff options
author | Jeremy Huddleston <[email protected]> | 2010-04-01 11:01:31 -0700 |
---|---|---|
committer | Jeremy Huddleston <[email protected]> | 2010-04-01 12:33:45 -0700 |
commit | 0594cf70883b64692ba617d85f4f9b4e636e5c2b (patch) | |
tree | 4f0180af9c072c393e3d6270825953bf46a9152e /src/glx/glxcurrent.c | |
parent | 86a7978d37393ee34f876569ac06ffdb8d7289ae (diff) |
apple: Initial import of libGL for OSX from AppleSGLX svn repository.
Signed-off-by: Jeremy Huddleston <[email protected]>
Diffstat (limited to 'src/glx/glxcurrent.c')
-rw-r--r-- | src/glx/glxcurrent.c | 53 |
1 files changed, 48 insertions, 5 deletions
diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c index c28360bdde9..115fab4012c 100644 --- a/src/glx/glxcurrent.c +++ b/src/glx/glxcurrent.c @@ -33,9 +33,20 @@ * Client-side GLX interface for current context management. */ +#ifdef PTHREADS +#include <pthread.h> +#endif + #include "glxclient.h" +#ifdef GLX_USE_APPLEGL +#include <stdlib.h> + +#include "apple_glx.h" +#include "apple_glx_context.h" +#else #include "glapi.h" #include "indirect_init.h" +#endif /* ** We setup some dummy structures here so that the API can be used @@ -59,11 +70,12 @@ static __GLXcontext dummyContext = { }; +#ifndef GLX_USE_APPLEGL /* ** All indirect rendering contexts will share the same indirect dispatch table. */ static __GLapi *IndirectAPI = NULL; - +#endif /* * Current context management and locking @@ -156,10 +168,12 @@ _X_HIDDEN void __glXSetCurrentContextNull(void) { __glXSetCurrentContext(&dummyContext); +#ifndef GLX_USE_APPLEGL #ifdef GLX_DIRECT_RENDERING _glapi_set_dispatch(NULL); /* no-op functions */ _glapi_set_context(NULL); #endif +#endif } @@ -186,6 +200,7 @@ glXGetCurrentDrawable(void) } +#ifndef GLX_USE_APPLEGL /************************************************************************/ /** @@ -313,6 +328,8 @@ __glXGenerateError(Display * dpy, GLXContext gc, XID resource, _XError(dpy, &error); } +#endif /* GLX_USE_APPLEGL */ + /** * Make a particular context current. * @@ -322,8 +339,17 @@ static Bool MakeContextCurrent(Display * dpy, GLXDrawable draw, GLXDrawable read, GLXContext gc) { - xGLXMakeCurrentReply reply; const GLXContext oldGC = __glXGetCurrentContext(); +#ifdef GLX_USE_APPLEGL + bool error = apple_glx_make_current_context(dpy, + (oldGC && oldGC != &dummyContext) ? oldGC->apple : NULL, + gc ? gc->apple : NULL, draw); + + apple_glx_diagnostic("%s: error %s\n", __func__, error ? "YES" : "NO"); + if(error) + return GL_FALSE; +#else + xGLXMakeCurrentReply reply; const CARD8 opcode = __glXSetupForCommand(dpy); const CARD8 oldOpcode = ((gc == oldGC) || (oldGC == &dummyContext)) ? opcode : __glXSetupForCommand(oldGC->currentDpy); @@ -419,6 +445,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, } #endif +#endif /* GLX_USE_APPLEGL */ /* Update our notion of what is current */ __glXLock(); @@ -428,8 +455,10 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, * cannot be NULL, therefore if they are the same, gc is not * NULL and not the dummy. */ - gc->currentDrawable = draw; - gc->currentReadable = read; + if(gc) { + gc->currentDrawable = draw; + gc->currentReadable = read; + } } else { if (oldGC != &dummyContext) { @@ -439,7 +468,18 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, oldGC->currentReadable = None; oldGC->currentContextTag = 0; oldGC->thread_id = 0; - +#ifdef GLX_USE_APPLEGL + + /* + * At this point we should check if the context has been + * through glXDestroyContext, and redestroy it if so. + */ + if(oldGC->do_destroy) { + __glXUnlock(); + /* glXDestroyContext uses the same global lock. */ + glXDestroyContext(dpy, oldGC); + __glXLock(); +#else if (oldGC->xid == None) { /* We are switching away from a context that was * previously destroyed, so we need to free the memory @@ -455,6 +495,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, } #endif __glXFreeContext(oldGC); +#endif /* GLX_USE_APPLEGL */ } } if (gc) { @@ -463,6 +504,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, gc->currentDpy = dpy; gc->currentDrawable = draw; gc->currentReadable = read; +#ifndef GLX_USE_APPLEGL gc->thread_id = _glthread_GetID(); #ifdef GLX_DIRECT_RENDERING @@ -486,6 +528,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, gc->currentContextTag = -1; } #endif +#endif /* GLX_USE_APPLEGL */ } else { __glXSetCurrentContextNull(); |