-/* $Id: context.c,v 1.20 1999/11/15 22:21:47 brianp Exp $ */
+/* $Id: context.c,v 1.21 1999/11/19 22:26:52 brianp Exp $ */
/*
* Mesa 3-D graphics library
#ifdef THREADS
-#include "mthreads.h" /* Mesa platform independent threads interface */
-
+#include "mthreads.h"
static MesaTSD mesa_ctx_tsd;
-
static void mesa_ctx_thread_init() {
MesaInitTSD(&mesa_ctx_tsd);
}
-GLcontext *gl_get_thread_context( void ) {
- return (GLcontext *) MesaGetTSD(&mesa_ctx_tsd);
-}
-
-static void set_thread_context( GLcontext *ctx ) {
- MesaSetTSD(&mesa_ctx_tsd, ctx, mesa_ctx_thread_init);
-}
-
-
#else
/* One Current Context pointer for all threads in the address space */
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(oldCtx, "gl_make_current");
}
-#ifdef THREADS
- /* TODO: unbind old buffer from context? */
- set_thread_context( newCtx );
-#else
if (oldCtx && oldCtx->Buffer) {
/* unbind frame buffer from context */
oldCtx->Buffer = NULL;
}
+
+#ifdef THREADS
+ /* TODO: unbind old buffer from context? */
+ MesaSetTSD(&mesa_ctx_tsd, (void *) newCtx, mesa_ctx_thread_init);
+#else
_mesa_current_context = newCtx;
+#endif
if (newCtx) {
SET_IMMEDIATE(newCtx, newCtx->input);
}
-#endif
if (newCtx)
_glapi_set_dispatch(newCtx->CurrentDispatch);
/*
- * Return current context handle.
+ * Return current context handle for the calling thread.
*/
GLcontext *gl_get_current_context( void )
{
#ifdef THREADS
- return gl_get_thread_context();
+ return (GLcontext *) MesaGetTSD(&mesa_ctx_tsd);
#else
return _mesa_current_context;
#endif
-/* $Id: context.h,v 1.2 1999/11/11 01:22:25 brianp Exp $ */
+/* $Id: context.h,v 1.3 1999/11/19 22:26:53 brianp Exp $ */
/*
* Mesa 3-D graphics library
#include "types.h"
-#ifdef THREADS
- /*
- * A seperate GLcontext for each thread
- */
- extern GLcontext *gl_get_thread_context( void );
-
-#define GET_IMMEDIATE struct immediate *IM = (gl_get_thread_context())->input;
-#define SET_IMMEDIATE(ctx, im) \
-do { \
- ctx->input = im; \
-} while (0)
-
-
-#else
- /*
- * All threads use same pointer to current context.
- */
- extern GLcontext *_mesa_current_context;
- extern struct immediate *CURRENT_INPUT;
- #define GET_CURRENT_CONTEXT(C) GLcontext *C = _mesa_current_context
-
-#define GET_IMMEDIATE struct immediate *IM = CURRENT_INPUT
-#define SET_IMMEDIATE(ctx, im) \
-do { \
- ctx->input = im; \
- CURRENT_INPUT = im; \
-} while (0)
-
-
-#endif
-
-
-
/*
* There are three Mesa datatypes which are meant to be used by device
* drivers:
*/
extern void gl_context_initialize( GLcontext *ctx );
+
+extern void gl_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask);
+
+
/*
* Create/destroy a GLframebuffer. A GLframebuffer is like a GLX drawable.
* It bundles up the depth buffer, stencil buffer and accum buffers into a
extern GLcontext *gl_get_current_context(void);
-extern void gl_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask);
+
+#ifdef THREADS
+ /*
+ * A seperate GLcontext for each thread
+ */
+
+ #define GET_CURRENT_CONTEXT(C) GLcontext *C = gl_get_current_context()
+
+#define GET_IMMEDIATE struct immediate *IM = (gl_get_current_context())->input;
+#define SET_IMMEDIATE(ctx, im) \
+do { \
+ ctx->input = im; \
+} while (0)
+
+
+#else
+ /*
+ * All threads use same pointer to current context.
+ */
+ extern GLcontext *_mesa_current_context;
+ extern struct immediate *CURRENT_INPUT;
+ #define GET_CURRENT_CONTEXT(C) GLcontext *C = _mesa_current_context
+
+#define GET_IMMEDIATE struct immediate *IM = CURRENT_INPUT
+#define SET_IMMEDIATE(ctx, im) \
+do { \
+ ctx->input = im; \
+ CURRENT_INPUT = im; \
+} while (0)
+
+
+#endif
+
+
extern void
_mesa_swapbuffers(GLcontext *ctx);