free_shared_state( GLcontext *ctx, struct gl_shared_state *ss );
-/**********************************************************************/
-/** \name OpenGL SI-style interface (new in Mesa 3.5)
- *
- * \if subset
- * \note Most of these functions are never called in the Mesa subset.
- * \endif
- */
-/*@{*/
-
-/**
- * Destroy context callback.
- *
- * \param gc context.
- * \return GL_TRUE on success, or GL_FALSE on failure.
- *
- * \ifnot subset
- * Called by window system/device driver (via __GLexports::destroyCurrent) when
- * the rendering context is to be destroyed.
- * \endif
- *
- * Frees the context data and the context structure.
- */
-GLboolean
-_mesa_destroyContext(__GLcontext *gc)
-{
- if (gc) {
- _mesa_free_context_data(gc);
- _mesa_free(gc);
- }
- return GL_TRUE;
-}
-
-/**
- * Unbind context callback.
- *
- * \param gc context.
- * \return GL_TRUE on success, or GL_FALSE on failure.
- *
- * \ifnot subset
- * Called by window system/device driver (via __GLexports::loseCurrent)
- * when the rendering context is made non-current.
- * \endif
- *
- * No-op
- */
-GLboolean
-_mesa_loseCurrent(__GLcontext *gc)
-{
- /* XXX unbind context from thread */
- (void) gc;
- return GL_TRUE;
-}
-
-/**
- * Bind context callback.
- *
- * \param gc context.
- * \return GL_TRUE on success, or GL_FALSE on failure.
- *
- * \ifnot subset
- * Called by window system/device driver (via __GLexports::makeCurrent)
- * when the rendering context is made current.
- * \endif
- *
- * No-op
- */
-GLboolean
-_mesa_makeCurrent(__GLcontext *gc)
-{
- /* XXX bind context to thread */
- (void) gc;
- return GL_TRUE;
-}
-
-/**
- * Share context callback.
- *
- * \param gc context.
- * \param gcShare shared context.
- * \return GL_TRUE on success, or GL_FALSE on failure.
- *
- * \ifnot subset
- * Called by window system/device driver (via __GLexports::shareContext)
- * \endif
- *
- * Update the shared context reference count, gl_shared_state::RefCount.
- */
-GLboolean
-_mesa_shareContext(__GLcontext *gc, __GLcontext *gcShare)
-{
- if (gc && gcShare && gc->Shared && gcShare->Shared) {
- gc->Shared->RefCount--;
- if (gc->Shared->RefCount == 0) {
- free_shared_state(gc, gc->Shared);
- }
- gc->Shared = gcShare->Shared;
- gc->Shared->RefCount++;
- return GL_TRUE;
- }
- else {
- return GL_FALSE;
- }
-}
-
-
-#if _HAVE_FULL_GL
-/**
- * Copy context callback.
- */
-GLboolean
-_mesa_copyContext(__GLcontext *dst, const __GLcontext *src, GLuint mask)
-{
- if (dst && src) {
- _mesa_copy_context( src, dst, mask );
- return GL_TRUE;
- }
- else {
- return GL_FALSE;
- }
-}
-#endif
-
-/** No-op */
-GLboolean
-_mesa_forceCurrent(__GLcontext *gc)
-{
- (void) gc;
- return GL_TRUE;
-}
-
-/**
- * Windows/buffer resizing notification callback.
- *
- * \param gc GL context.
- * \return GL_TRUE on success, or GL_FALSE on failure.
- */
-GLboolean
-_mesa_notifyResize(__GLcontext *gc)
-{
- /* update viewport, resize software buffers, etc. */
- (void) gc;
- return GL_TRUE;
-}
-
-/**
- * Window/buffer destruction notification callback.
- *
- * \param gc GL context.
- *
- * Called when the context's window/buffer is going to be destroyed.
- *
- * No-op
- */
-void
-_mesa_notifyDestroy(__GLcontext *gc)
-{
- /* Unbind from it. */
- (void) gc;
-}
-
/**
* Swap buffers notification callback.
*
FLUSH_VERTICES( gc, 0 );
}
-/** No-op */
-struct __GLdispatchStateRec *
-_mesa_dispatchExec(__GLcontext *gc)
-{
- (void) gc;
- return NULL;
-}
-
-/** No-op */
-void
-_mesa_beginDispatchOverride(__GLcontext *gc)
-{
- (void) gc;
-}
-
-/** No-op */
-void
-_mesa_endDispatchOverride(__GLcontext *gc)
-{
- (void) gc;
-}
-
-/**
- * \ifnot subset
- * Setup the exports.
- *
- * The window system will call these functions when it needs Mesa to do
- * something.
- *
- * \note Device drivers should override these functions! For example,
- * the Xlib driver should plug in the XMesa*-style functions into this
- * structure. The XMesa-style functions should then call the _mesa_*
- * version of these functions. This is an approximation to OO design
- * (inheritance and virtual functions).
- * \endif
- *
- * \if subset
- * No-op.
- *
- * \endif
- */
-static void
-_mesa_init_default_exports(__GLexports *exports)
-{
-#if _HAVE_FULL_GL
- exports->destroyContext = _mesa_destroyContext;
- exports->loseCurrent = _mesa_loseCurrent;
- exports->makeCurrent = _mesa_makeCurrent;
- exports->shareContext = _mesa_shareContext;
- exports->copyContext = _mesa_copyContext;
- exports->forceCurrent = _mesa_forceCurrent;
- exports->notifyResize = _mesa_notifyResize;
- exports->notifyDestroy = _mesa_notifyDestroy;
- exports->notifySwapBuffers = _mesa_notifySwapBuffers;
- exports->dispatchExec = _mesa_dispatchExec;
- exports->beginDispatchOverride = _mesa_beginDispatchOverride;
- exports->endDispatchOverride = _mesa_endDispatchOverride;
-#else
- (void) exports;
-#endif
-}
-
-/**
- * Exported OpenGL SI interface.
- */
-__GLcontext *
-__glCoreCreateContext(__GLimports *imports, __GLcontextModes *modes)
-{
- GLcontext *ctx;
-
- ctx = (GLcontext *) (*imports->calloc)(NULL, 1, sizeof(GLcontext));
- if (ctx == NULL) {
- return NULL;
- }
-
- /* XXX doesn't work at this time */
- _mesa_initialize_context(ctx, modes, NULL, NULL, NULL);
- ctx->imports = *imports;
-
- return ctx;
-}
-
-/**
- * Exported OpenGL SI interface.
- */
-void
-__glCoreNopDispatch(void)
-{
-#if 0
- /* SI */
- __gl_dispatch = __glNopDispatchState;
-#else
- /* Mesa */
- _glapi_set_dispatch(NULL);
-#endif
-}
-
-/*@}*/
-
/**********************************************************************/
/** \name GL Visual allocation/destruction */
assert( sizeof(GLint) == 4 );
assert( sizeof(GLuint) == 4 );
+ _mesa_init_sqrt_table();
+
#if _HAVE_FULL_GL
_math_init();
assert(driverFunctions->NewTextureObject);
assert(driverFunctions->FreeTexImageData);
- /* If the driver wants core Mesa to use special imports, it'll have to
- * override these defaults.
- */
- _mesa_init_default_imports( &(ctx->imports), driverContext );
-
- /* initialize the exports (Mesa functions called by the window system) */
- _mesa_init_default_exports( &(ctx->exports) );
-
/* misc one-time initializations */
one_time_init(ctx);
*/
static short sqrttab[0x100]; /* declare table of square roots */
-static void init_sqrt_table(void)
+void
+_mesa_init_sqrt_table(void)
{
#if defined(USE_IEEE) && !defined(DEBUG)
unsigned short i;
/*@}*/
-/**********************************************************************/
-/** \name Exit */
-/*@{*/
-
/**
* Wrapper for exit().
*/
{
exit(status);
}
-
-/*@}*/
-
-
-/**********************************************************************/
-/** \name Default Imports Wrapper */
-/*@{*/
-
-/** Wrapper around _mesa_malloc() */
-static void *
-default_malloc(__GLcontext *gc, size_t size)
-{
- (void) gc;
- return _mesa_malloc(size);
-}
-
-/** Wrapper around _mesa_malloc() */
-static void *
-default_calloc(__GLcontext *gc, size_t numElem, size_t elemSize)
-{
- (void) gc;
- return _mesa_calloc(numElem * elemSize);
-}
-
-/** Wrapper around realloc() */
-static void *
-default_realloc(__GLcontext *gc, void *oldAddr, size_t newSize)
-{
- (void) gc;
- return realloc(oldAddr, newSize);
-}
-
-/** Wrapper around _mesa_free() */
-static void
-default_free(__GLcontext *gc, void *addr)
-{
- (void) gc;
- _mesa_free(addr);
-}
-
-/** Wrapper around _mesa_getenv() */
-static char * CAPI
-default_getenv( __GLcontext *gc, const char *var )
-{
- (void) gc;
- return _mesa_getenv(var);
-}
-
-/** Wrapper around _mesa_warning() */
-static void
-default_warning(__GLcontext *gc, char *str)
-{
- _mesa_warning(gc, str);
-}
-
-/** Wrapper around _mesa_problem() */
-static void
-default_fatal(__GLcontext *gc, char *str)
-{
- _mesa_problem(gc, str);
- abort();
-}
-
-/** Wrapper around atoi() */
-static int CAPI
-default_atoi(__GLcontext *gc, const char *str)
-{
- (void) gc;
- return atoi(str);
-}
-
-/** Wrapper around vsprintf() */
-static int CAPI
-default_sprintf(__GLcontext *gc, char *str, const char *fmt, ...)
-{
- int r;
- va_list args;
- (void) gc;
- va_start( args, fmt );
- r = vsprintf( str, fmt, args );
- va_end( args );
- return r;
-}
-
-/** Wrapper around fopen() */
-static void * CAPI
-default_fopen(__GLcontext *gc, const char *path, const char *mode)
-{
- (void) gc;
- return fopen(path, mode);
-}
-
-/** Wrapper around fclose() */
-static int CAPI
-default_fclose(__GLcontext *gc, void *stream)
-{
- (void) gc;
- return fclose((FILE *) stream);
-}
-
-/** Wrapper around vfprintf() */
-static int CAPI
-default_fprintf(__GLcontext *gc, void *stream, const char *fmt, ...)
-{
- int r;
- va_list args;
- (void) gc;
- va_start( args, fmt );
- r = vfprintf( (FILE *) stream, fmt, args );
- va_end( args );
- return r;
-}
-
-/*@}*/
-
-
-/**
- * Initialize a __GLimports object to point to the functions in this
- * file.
- *
- * This is to be called from device drivers.
- *
- * Also, do some one-time initializations.
- *
- * \param imports the object to initialize.
- * \param driverCtx pointer to device driver-specific data.
- */
-void
-_mesa_init_default_imports(__GLimports *imports, void *driverCtx)
-{
- /* XXX maybe move this one-time init stuff into context.c */
- static GLboolean initialized = GL_FALSE;
- if (!initialized) {
- init_sqrt_table();
- initialized = GL_TRUE;
- }
-
- imports->malloc = default_malloc;
- imports->calloc = default_calloc;
- imports->realloc = default_realloc;
- imports->free = default_free;
- imports->warning = default_warning;
- imports->fatal = default_fatal;
- imports->getenv = default_getenv; /* not used for now */
- imports->atoi = default_atoi;
- imports->sprintf = default_sprintf;
- imports->fopen = default_fopen;
- imports->fclose = default_fclose;
- imports->fprintf = default_fprintf;
- imports->getDrawablePrivate = NULL; /* driver-specific */
- imports->getReadablePrivate = NULL; /* driver-specific */
- imports->other = driverCtx;
-}