From 9a33a11d714c90162d32781ebbd2c1dfab52cfd1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 13 Jun 2002 04:28:29 +0000 Subject: New _mesa_debug() function to replace fprintf() calls. Some source files updated to call _mesa_debug(), but not finished. Added __GLimports as a parameter to _mesa_create/init_context() and updated drivers accordingly. Fleshed-out more of the __GLimports and __GLexports functionality. Removed run-time config file support (config.c) --- src/mesa/main/Makefile.DJ | 1 - src/mesa/main/Makefile.OSMesa16 | 3 +- src/mesa/main/Makefile.X11 | 3 +- src/mesa/main/Makefile.ugl | 1 - src/mesa/main/Makefile.win | 1 - src/mesa/main/attrib.c | 11 +-- src/mesa/main/blend.c | 14 +-- src/mesa/main/buffers.c | 12 +-- src/mesa/main/context.c | 210 +++++++++++++++++++++++++++++++++------- src/mesa/main/context.h | 75 +++++++++----- src/mesa/main/depth.c | 10 +- src/mesa/main/dlist.c | 12 +-- src/mesa/main/enable.c | 10 +- src/mesa/main/feedback.c | 8 +- src/mesa/main/get.c | 14 +-- src/mesa/main/glheader.h | 5 +- src/mesa/main/hint.c | 8 +- src/mesa/main/imports.c | 30 +++--- src/mesa/main/imports.h | 8 +- src/mesa/main/light.c | 30 +++--- src/mesa/main/matrix.c | 12 +-- src/mesa/main/mtypes.h | 6 +- 22 files changed, 330 insertions(+), 154 deletions(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/Makefile.DJ b/src/mesa/main/Makefile.DJ index afe95f0c36..4749bfd849 100644 --- a/src/mesa/main/Makefile.DJ +++ b/src/mesa/main/Makefile.DJ @@ -60,7 +60,6 @@ CORE_SOURCES = \ buffers.c \ clip.c \ colortab.c \ - config.c \ context.c \ convolve.c \ debug.c \ diff --git a/src/mesa/main/Makefile.OSMesa16 b/src/mesa/main/Makefile.OSMesa16 index eeb32a264b..4613f1a270 100644 --- a/src/mesa/main/Makefile.OSMesa16 +++ b/src/mesa/main/Makefile.OSMesa16 @@ -1,4 +1,4 @@ -# $Id: Makefile.OSMesa16,v 1.6 2002/02/02 21:41:58 brianp Exp $ +# $Id: Makefile.OSMesa16,v 1.7 2002/06/13 04:28:29 brianp Exp $ # Mesa 3-D graphics library # Version: 4.1 @@ -31,7 +31,6 @@ CORE_SOURCES = \ buffers.c \ clip.c \ colortab.c \ - config.c \ context.c \ convolve.c \ debug.c \ diff --git a/src/mesa/main/Makefile.X11 b/src/mesa/main/Makefile.X11 index 8ab3a30849..19a90b03b2 100644 --- a/src/mesa/main/Makefile.X11 +++ b/src/mesa/main/Makefile.X11 @@ -1,4 +1,4 @@ -# $Id: Makefile.X11,v 1.67 2002/04/09 14:58:03 keithw Exp $ +# $Id: Makefile.X11,v 1.68 2002/06/13 04:28:29 brianp Exp $ # Mesa 3-D graphics library # Version: 4.1 @@ -31,7 +31,6 @@ CORE_SOURCES = \ buffers.c \ clip.c \ colortab.c \ - config.c \ context.c \ convolve.c \ debug.c \ diff --git a/src/mesa/main/Makefile.ugl b/src/mesa/main/Makefile.ugl index 92ca94c9f2..f8f00fa411 100644 --- a/src/mesa/main/Makefile.ugl +++ b/src/mesa/main/Makefile.ugl @@ -61,7 +61,6 @@ GL_SOURCES = \ buffers.c \ clip.c \ colortab.c \ - config.c \ context.c \ convolve.c \ debug.c \ diff --git a/src/mesa/main/Makefile.win b/src/mesa/main/Makefile.win index a536d1e4ea..77814140a7 100644 --- a/src/mesa/main/Makefile.win +++ b/src/mesa/main/Makefile.win @@ -46,7 +46,6 @@ CORE_SRCS = \ buffers.c \ clip.c \ colortab.c \ - config.c \ context.c \ convolve.c \ debug.c \ diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index b75fe4d625..f5f611784b 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1,4 +1,4 @@ -/* $Id: attrib.c,v 1.65 2002/06/07 16:01:03 brianp Exp $ */ +/* $Id: attrib.c,v 1.66 2002/06/13 04:28:29 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -119,8 +119,8 @@ _mesa_PushAttrib(GLbitfield mask) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); - if (MESA_VERBOSE&VERBOSE_API) - fprintf(stderr, "glPushAttrib %x\n", (int)mask); + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug("glPushAttrib %x\n", (int) mask); if (ctx->AttribStackDepth >= MAX_ATTRIB_STACK_DEPTH) { _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushAttrib" ); @@ -801,9 +801,8 @@ _mesa_PopAttrib(void) while (attr) { - if (MESA_VERBOSE&VERBOSE_API) { - fprintf(stderr, "glPopAttrib %s\n", - _mesa_lookup_enum_by_nr(attr->kind)); + if (MESA_VERBOSE & VERBOSE_API) { + _mesa_debug("glPopAttrib %s\n", _mesa_lookup_enum_by_nr(attr->kind)); } switch (attr->kind) { diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index b00e834d4f..6d5b6a13f5 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -1,10 +1,10 @@ -/* $Id: blend.c,v 1.34 2001/09/14 21:36:43 brianp Exp $ */ +/* $Id: blend.c,v 1.35 2002/06/13 04:28:29 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -46,7 +46,7 @@ _mesa_BlendFunc( GLenum sfactor, GLenum dfactor ) ASSERT_OUTSIDE_BEGIN_END(ctx); if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - fprintf(stderr, "glBlendFunc %s %s\n", + _mesa_debug("glBlendFunc %s %s\n", _mesa_lookup_enum_by_nr(sfactor), _mesa_lookup_enum_by_nr(dfactor)); @@ -127,7 +127,7 @@ _mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB, ASSERT_OUTSIDE_BEGIN_END(ctx); if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - fprintf(stderr, "glBlendFuncSeparate %s %s %s %s\n", + _mesa_debug("glBlendFuncSeparate %s %s %s %s\n", _mesa_lookup_enum_by_nr(sfactorRGB), _mesa_lookup_enum_by_nr(dfactorRGB), _mesa_lookup_enum_by_nr(sfactorA), @@ -268,7 +268,7 @@ _mesa_BlendEquation( GLenum mode ) ASSERT_OUTSIDE_BEGIN_END(ctx); if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - fprintf(stderr, "glBlendEquation %s\n", + _mesa_debug("glBlendEquation %s\n", _mesa_lookup_enum_by_nr(mode)); switch (mode) { @@ -445,7 +445,7 @@ _mesa_ColorMask( GLboolean red, GLboolean green, ASSERT_OUTSIDE_BEGIN_END(ctx); if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "glColorMask %d %d %d %d\n", red, green, blue, alpha); + _mesa_debug("glColorMask %d %d %d %d\n", red, green, blue, alpha); /* Shouldn't have any information about channel depth in core mesa * -- should probably store these as the native booleans: diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index e1706c3255..295921e1d0 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -1,4 +1,4 @@ -/* $Id: buffers.c,v 1.34 2002/04/19 00:23:08 brianp Exp $ */ +/* $Id: buffers.c,v 1.35 2002/06/13 04:28:29 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -97,7 +97,7 @@ _mesa_Clear( GLbitfield mask ) ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "glClear 0x%x\n", mask); + _mesa_debug("glClear 0x%x\n", mask); if (mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | @@ -146,7 +146,7 @@ _mesa_DrawBuffer( GLenum mode ) if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(mode)); + _mesa_debug("glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(mode)); switch (mode) { case GL_AUX0: @@ -298,7 +298,7 @@ _mesa_ReadBuffer( GLenum mode ) ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(mode)); + _mesa_debug("glReadBuffer %s\n", _mesa_lookup_enum_by_nr(mode)); switch (mode) { case GL_AUX0: @@ -360,7 +360,7 @@ _mesa_ResizeBuffersMESA( void ) GLcontext *ctx = _mesa_get_current_context(); if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "glResizeBuffersMESA\n"); + _mesa_debug("glResizeBuffersMESA\n"); if (ctx) { ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx ); @@ -416,7 +416,7 @@ _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height ) } if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "glScissor %d %d %d %d\n", x, y, width, height); + _mesa_debug("glScissor %d %d %d %d\n", x, y, width, height); if (x == ctx->Scissor.X && y == ctx->Scissor.Y && diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 420bfa4691..bb43659063 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1,4 +1,4 @@ -/* $Id: context.c,v 1.163 2002/05/27 17:04:52 brianp Exp $ */ +/* $Id: context.c,v 1.164 2002/06/13 04:28:29 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -41,7 +41,6 @@ #include "get.h" #include "glthread.h" #include "hash.h" -#include "imports.h" #include "light.h" #include "macros.h" #include "mem.h" @@ -78,13 +77,19 @@ int MESA_DEBUG_FLAGS = 0; #endif +static void +free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ); + /**********************************************************************/ /***** OpenGL SI-style interface (new in Mesa 3.5) *****/ /**********************************************************************/ -static GLboolean -_mesa_DestroyContext(__GLcontext *gc) +/* Called by window system/device driver (via gc->exports.destroyCurrent()) + * when the rendering context is to be destroyed. + */ +GLboolean +_mesa_destroyContext(__GLcontext *gc) { if (gc) { _mesa_free_context_data(gc); @@ -93,6 +98,133 @@ _mesa_DestroyContext(__GLcontext *gc) return GL_TRUE; } +/* Called by window system/device driver (via gc->exports.loseCurrent()) + * when the rendering context is made non-current. + */ +GLboolean +_mesa_loseCurrent(__GLcontext *gc) +{ + /* XXX unbind context from thread */ + return GL_TRUE; +} + +/* Called by window system/device driver (via gc->exports.makeCurrent()) + * when the rendering context is made current. + */ +GLboolean +_mesa_makeCurrent(__GLcontext *gc) +{ + /* XXX bind context to thread */ + return GL_TRUE; +} + +/* Called by window system/device driver - yadda, yadda, yadda. + * See above comments. + */ +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; + } +} + +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; + } +} + +GLboolean +_mesa_forceCurrent(__GLcontext *gc) +{ + return GL_TRUE; +} + +GLboolean +_mesa_notifyResize(__GLcontext *gc) +{ + GLint x, y; + GLuint width, height; + __GLdrawablePrivate *d = gc->imports.getDrawablePrivate(gc); + if (!d || !d->getDrawableSize) + return GL_FALSE; + d->getDrawableSize( d, &x, &y, &width, &height ); + /* update viewport, resize software buffers, etc. */ + return GL_TRUE; +} + +void +_mesa_notifyDestroy(__GLcontext *gc) +{ +} + +/* Called by window system just before swapping buffers. + * We have to finish any pending rendering. + */ +void +_mesa_notifySwapBuffers(__GLcontext *gc) +{ + FLUSH_VERTICES( gc, 0 ); +} + +struct __GLdispatchStateRec * +_mesa_dispatchExec(__GLcontext *gc) +{ + return NULL; +} + +void +_mesa_beginDispatchOverride(__GLcontext *gc) +{ +} + +void +_mesa_endDispatchOverride(__GLcontext *gc) +{ +} + +/* 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). + */ +static void +_mesa_init_default_exports(__GLexports *exports) +{ + 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_notifyCestroy; + exports->notifySwapBuffers = _mesa_notifySwapBuffers; + exports->dispatchExec = _mesa_dispatchExec; + exports->beginDispatchOverride = _mesa_beginDispatchOverride; + exports->endDispatchOverride = _mesa_endDispatchOverride; +} + + /* exported OpenGL SI interface */ __GLcontext * @@ -104,7 +236,7 @@ __glCoreCreateContext(__GLimports *imports, __GLcontextModes *modes) if (ctx == NULL) { return NULL; } - ctx->Driver.CurrentExecPrimitive=0; + ctx->Driver.CurrentExecPrimitive=0; /* XXX why is this here??? */ ctx->imports = *imports; _mesa_initialize_visual(&ctx->Visual, @@ -124,10 +256,7 @@ __glCoreCreateContext(__GLimports *imports, __GLcontextModes *modes) modes->accumAlphaBits, 0); - /* KW: was imports->wscx */ - _mesa_initialize_context(ctx, &ctx->Visual, NULL, imports->other, GL_FALSE); - - ctx->exports.destroyContext = _mesa_DestroyContext; + _mesa_initialize_context(ctx, &ctx->Visual, NULL, imports); return ctx; } @@ -147,12 +276,6 @@ __glCoreNopDispatch(void) } -/**********************************************************************/ -/***** Context and Thread management *****/ -/**********************************************************************/ - - - /**********************************************************************/ /***** GL Visual allocation/destruction *****/ /**********************************************************************/ @@ -1472,25 +1595,30 @@ GLboolean _mesa_initialize_context( GLcontext *ctx, const GLvisual *visual, GLcontext *share_list, - void *driver_ctx, - GLboolean direct ) + const __GLimports *imports ) { GLuint dispatchSize; - (void) direct; /* not used */ + ASSERT(imports); + ASSERT(imports->other); /* other points to the device driver's context */ /* misc one-time initializations */ one_time_init(); + /* initialize the exports (Mesa functions called by the window system) */ + _mesa_init_default_exports( &(ctx->exports) ); + +#if 0 /** ** OpenGL SI stuff **/ if (!ctx->imports.malloc) { - _mesa_InitDefaultImports(&ctx->imports, driver_ctx, NULL); + _mesa_init_default_imports(&ctx->imports, driver_ctx); } /* exports are setup by the device driver */ +#endif - ctx->DriverCtx = driver_ctx; + ctx->DriverCtx = imports->other; ctx->Visual = *visual; ctx->DrawBuffer = NULL; ctx->ReadBuffer = NULL; @@ -1643,21 +1771,20 @@ _mesa_initialize_context( GLcontext *ctx, * Allocate and initialize a GLcontext structure. * Input: visual - a GLvisual pointer (we copy the struct contents) * sharelist - another context to share display lists with or NULL - * driver_ctx - pointer to device driver's context state struct + * imports - points to a fully-initialized __GLimports object. * Return: pointer to a new __GLcontextRec or NULL if error. */ GLcontext * _mesa_create_context( const GLvisual *visual, GLcontext *share_list, - void *driver_ctx, - GLboolean direct ) + const __GLimports *imports ) { GLcontext *ctx = (GLcontext *) CALLOC( sizeof(GLcontext) ); if (!ctx) { return NULL; } - ctx->Driver.CurrentExecPrimitive = 0; - if (_mesa_initialize_context(ctx, visual, share_list, driver_ctx, direct)) { + ctx->Driver.CurrentExecPrimitive = 0; /* XXX why is this here??? */ + if (_mesa_initialize_context(ctx, visual, share_list, imports)) { return ctx; } else { @@ -1879,15 +2006,6 @@ _mesa_copy_context( const GLcontext *src, GLcontext *dst, GLuint mask ) } -/* - * Set the current context, binding the given frame buffer to the context. - */ -void -_mesa_make_current( GLcontext *newCtx, GLframebuffer *buffer ) -{ - _mesa_make_current2( newCtx, buffer, buffer ); -} - static void print_info( void ) { @@ -1917,6 +2035,16 @@ static void print_info( void ) } +/* + * Set the current context, binding the given frame buffer to the context. + */ +void +_mesa_make_current( GLcontext *newCtx, GLframebuffer *buffer ) +{ + _mesa_make_current2( newCtx, buffer, buffer ); +} + + /* * Bind the given context to the given draw-buffer and read-buffer * and make it the current context for this thread. @@ -2133,6 +2261,20 @@ _mesa_error( GLcontext *ctx, GLenum error, const char *where ) } +/* + * Call this to report debug information. + */ +#ifdef DEBUG +void +_mesa_debug( const char *fmtString, ... ) +{ + va_list args; + va_start( args, fmtString ); + (void) vfprintf( stderr, fmtString, args ); + va_end( args ); +} +#endif + void _mesa_Finish( void ) diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index e0bb2ad09f..49555ff6e2 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -1,4 +1,4 @@ -/* $Id: context.h,v 1.28 2001/12/14 02:50:01 brianp Exp $ */ +/* $Id: context.h,v 1.29 2002/06/13 04:28:29 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -53,9 +53,7 @@ /* - * Create/destroy a GLvisual. A GLvisual is like a GLX visual. It describes - * the colorbuffer, depth buffer, stencil buffer and accum buffer which will - * be used by the GL context and framebuffer. + * Create/destroy a GLvisual. */ extern GLvisual * _mesa_create_visual( GLboolean rgbFlag, @@ -98,9 +96,7 @@ _mesa_destroy_visual( GLvisual *vis ); /* - * Create/destroy a GLframebuffer. A GLframebuffer is like a GLX drawable. - * It bundles up the depth buffer, stencil buffer and accum buffers into a - * single entity. + * Create/destroy a GLframebuffer. */ extern GLframebuffer * _mesa_create_framebuffer( const GLvisual *visual, @@ -126,21 +122,18 @@ _mesa_destroy_framebuffer( GLframebuffer *buffer ); /* - * Create/destroy a GLcontext. A GLcontext is like a GLX context. It - * contains the rendering state. + * Create/destroy a GLcontext. */ extern GLcontext * _mesa_create_context( const GLvisual *visual, GLcontext *share_list, - void *driver_ctx, - GLboolean direct); + const __GLimports *imports ); extern GLboolean _mesa_initialize_context( GLcontext *ctx, const GLvisual *visual, GLcontext *share_list, - void *driver_ctx, - GLboolean direct ); + const __GLimports *imports ); extern void _mesa_free_context_data( GLcontext *ctx ); @@ -182,10 +175,50 @@ _mesa_get_current_context(void); +/* OpenGL SI-style export functions. */ + +extern GLboolean +_mesa_destroyContext(__GLcontext *gc); + +extern GLboolean +_mesa_loseCurrent(__GLcontext *gc); + +extern GLboolean +_mesa_makeCurrent(__GLcontext *gc); + +extern GLboolean +_mesa_shareContext(__GLcontext *gc, __GLcontext *gcShare); + +extern GLboolean +_mesa_copyContext(__GLcontext *dst, const __GLcontext *src, GLuint mask); + +extern GLboolean +_mesa_forceCurrent(__GLcontext *gc); + +extern GLboolean +_mesa_notifyResize(__GLcontext *gc); + extern void -_mesa_swapbuffers(GLcontext *ctx); +_mesa_notifyDestroy(__GLcontext *gc); + +extern void +_mesa_notifySwapBuffers(__GLcontext *gc); + +extern void +_mesa_dispatchExec(__GLcontext *gc); + +extern void +_mesa_beginDispatchOverride(__GLcontext *gc); + +extern void +_mesa_endDispatchOverride(__GLcontext *gc); + + +extern void +_mesa_swapbuffers(GLcontext *ctx); + extern struct _glapi_table * _mesa_get_dispatch(GLcontext *ctx); @@ -204,7 +237,10 @@ _mesa_warning( const GLcontext *ctx, const char *s ); extern void _mesa_error( GLcontext *ctx, GLenum error, const char *s ); - +#ifdef DEBUG +extern void +_mesa_debug( const char *fmtString, ... ); +#endif extern void _mesa_Finish( void ); @@ -213,13 +249,4 @@ extern void _mesa_Flush( void ); - -extern void -_mesa_read_config_file(GLcontext *ctx); - -extern void -_mesa_register_config_var(const char *name, - void (*notify)( const char *, int )); - - #endif diff --git a/src/mesa/main/depth.c b/src/mesa/main/depth.c index 36daf5c592..3c25550e94 100644 --- a/src/mesa/main/depth.c +++ b/src/mesa/main/depth.c @@ -1,10 +1,10 @@ -/* $Id: depth.c,v 1.28 2001/03/29 16:50:32 brianp Exp $ */ +/* $Id: depth.c,v 1.29 2002/06/13 04:28:29 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -70,7 +70,7 @@ _mesa_DepthFunc( GLenum func ) ASSERT_OUTSIDE_BEGIN_END(ctx); if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - fprintf(stderr, "glDepthFunc %s\n", _mesa_lookup_enum_by_nr(func)); + _mesa_debug("glDepthFunc %s\n", _mesa_lookup_enum_by_nr(func)); switch (func) { case GL_LESS: /* (default) pass if incoming z < stored z */ @@ -106,7 +106,7 @@ _mesa_DepthMask( GLboolean flag ) ASSERT_OUTSIDE_BEGIN_END(ctx); if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - fprintf(stderr, "glDepthMask %d\n", flag); + _mesa_debug("glDepthMask %d\n", flag); /* * GL_TRUE indicates depth buffer writing is enabled (default) diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 3ae3f67bc1..6b67b31675 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -1,4 +1,4 @@ -/* $Id: dlist.c,v 1.88 2002/05/29 15:16:01 brianp Exp $ */ +/* $Id: dlist.c,v 1.89 2002/06/13 04:28:29 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -4145,7 +4145,7 @@ execute_list( GLcontext *ctx, GLuint list ) if (ctx->Driver.BeginCallList) ctx->Driver.BeginCallList( ctx, list ); -/* fprintf(stderr, "execute list %d\n", list); */ +/* _mesa_debug("execute list %d\n", list); */ /* mesa_print_display_list( list ); */ ctx->CallDepth++; @@ -4936,7 +4936,7 @@ _mesa_NewList( GLuint list, GLenum mode ) ASSERT_OUTSIDE_BEGIN_END(ctx); if (MESA_VERBOSE&VERBOSE_API) - fprintf(stderr, "glNewList %u %s\n", list, _mesa_lookup_enum_by_nr(mode)); + _mesa_debug("glNewList %u %s\n", list, _mesa_lookup_enum_by_nr(mode)); if (list==0) { _mesa_error( ctx, GL_INVALID_VALUE, "glNewList" ); @@ -4983,7 +4983,7 @@ _mesa_EndList( void ) ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); if (MESA_VERBOSE&VERBOSE_API) - fprintf(stderr, "glEndList\n"); + _mesa_debug("glEndList\n"); /* Check that a list is under construction */ if (!ctx->CurrentListPtr) { @@ -5026,7 +5026,7 @@ _mesa_CallList( GLuint list ) if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "_mesa_CallList %d\n", list); + _mesa_debug("_mesa_CallList %d\n", list); /* mesa_print_display_list( list ); */ @@ -5059,7 +5059,7 @@ _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists ) GLboolean save_compile_flag; if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "_mesa_CallLists %d\n", n); + _mesa_debug("_mesa_CallLists %d\n", n); /* Save the CompileFlag status, turn it off, execute display list, * and restore the CompileFlag. diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 87db3d5a6f..5d29149ca0 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -1,4 +1,4 @@ -/* $Id: enable.c,v 1.63 2002/05/27 17:04:53 brianp Exp $ */ +/* $Id: enable.c,v 1.64 2002/06/13 04:28:29 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -173,10 +173,10 @@ _mesa_DisableClientState( GLenum cap ) void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) { if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "%s %s (newstate is %x)\n", - state ? "glEnable" : "glDisable", - _mesa_lookup_enum_by_nr(cap), - ctx->NewState); + _mesa_debug("%s %s (newstate is %x)\n", + state ? "glEnable" : "glDisable", + _mesa_lookup_enum_by_nr(cap), + ctx->NewState); switch (cap) { case GL_ALPHA_TEST: diff --git a/src/mesa/main/feedback.c b/src/mesa/main/feedback.c index fcd8714652..94ed866fdc 100644 --- a/src/mesa/main/feedback.c +++ b/src/mesa/main/feedback.c @@ -1,10 +1,10 @@ -/* $Id: feedback.c,v 1.24 2001/03/29 17:08:26 keithw Exp $ */ +/* $Id: feedback.c,v 1.25 2002/06/13 04:28:29 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -340,7 +340,7 @@ _mesa_RenderMode( GLenum mode ) ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "glRenderMode %s\n", _mesa_lookup_enum_by_nr(mode)); + _mesa_debug("glRenderMode %s\n", _mesa_lookup_enum_by_nr(mode)); FLUSH_VERTICES(ctx, _NEW_RENDERMODE); diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 0705f884e6..5770db9533 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1,4 +1,4 @@ -/* $Id: get.c,v 1.79 2002/05/27 17:04:53 brianp Exp $ */ +/* $Id: get.c,v 1.80 2002/06/13 04:28:29 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -128,7 +128,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) FLUSH_VERTICES(ctx, 0); if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "glGetBooleanv %s\n", _mesa_lookup_enum_by_nr(pname)); + _mesa_debug("glGetBooleanv %s\n", _mesa_lookup_enum_by_nr(pname)); if (ctx->Driver.GetBooleanv && (*ctx->Driver.GetBooleanv)(ctx, pname, params)) @@ -1465,7 +1465,7 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) FLUSH_VERTICES(ctx, 0); if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "glGetDoublev %s\n", _mesa_lookup_enum_by_nr(pname)); + _mesa_debug("glGetDoublev %s\n", _mesa_lookup_enum_by_nr(pname)); if (ctx->Driver.GetDoublev && (*ctx->Driver.GetDoublev)(ctx, pname, params)) return; @@ -2708,7 +2708,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) FLUSH_VERTICES(ctx, 0); if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "glGetFloatv %s\n", _mesa_lookup_enum_by_nr(pname)); + _mesa_debug("glGetFloatv %s\n", _mesa_lookup_enum_by_nr(pname)); if (ctx->Driver.GetFloatv && (*ctx->Driver.GetFloatv)(ctx, pname, params)) return; @@ -3920,7 +3920,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) FLUSH_VERTICES(ctx, 0); if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "glGetIntegerv %s\n", _mesa_lookup_enum_by_nr(pname)); + _mesa_debug("glGetIntegerv %s\n", _mesa_lookup_enum_by_nr(pname)); if (ctx->Driver.GetIntegerv && (*ctx->Driver.GetIntegerv)(ctx, pname, params)) @@ -5171,7 +5171,7 @@ _mesa_GetPointerv( GLenum pname, GLvoid **params ) return; if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "glGetPointerv %s\n", _mesa_lookup_enum_by_nr(pname)); + _mesa_debug("glGetPointerv %s\n", _mesa_lookup_enum_by_nr(pname)); if (ctx->Driver.GetPointerv && (*ctx->Driver.GetPointerv)(ctx, pname, params)) @@ -5271,7 +5271,7 @@ _mesa_GetError( void ) ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "glGetError <-- %s\n", _mesa_lookup_enum_by_nr(e)); + _mesa_debug("glGetError <-- %s\n", _mesa_lookup_enum_by_nr(e)); ctx->ErrorValue = (GLenum) GL_NO_ERROR; return e; diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h index 3a66f618a2..8a9cf4b82b 100644 --- a/src/mesa/main/glheader.h +++ b/src/mesa/main/glheader.h @@ -1,4 +1,4 @@ -/* $Id: glheader.h,v 1.26 2002/06/12 00:52:50 brianp Exp $ */ +/* $Id: glheader.h,v 1.27 2002/06/13 04:28:29 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -72,6 +72,9 @@ #include "conf.h" #endif +#ifdef DEBUG +#include /* for _mesa_debug() only */ +#endif #if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) diff --git a/src/mesa/main/hint.c b/src/mesa/main/hint.c index e37cfb1a87..d75823feb9 100644 --- a/src/mesa/main/hint.c +++ b/src/mesa/main/hint.c @@ -1,10 +1,10 @@ -/* $Id: hint.c,v 1.10 2001/05/21 16:41:03 brianp Exp $ */ +/* $Id: hint.c,v 1.11 2002/06/13 04:28:29 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -50,7 +50,7 @@ GLboolean _mesa_try_Hint( GLcontext *ctx, GLenum target, GLenum mode ) { if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "glHint %s %d\n", _mesa_lookup_enum_by_nr(target), mode); + _mesa_debug("glHint %s %d\n", _mesa_lookup_enum_by_nr(target), mode); if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) { _mesa_error(ctx, GL_INVALID_ENUM, "glHint(mode)"); diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 61fbf60915..b4e5dca930 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -1,10 +1,10 @@ -/* $Id: imports.c,v 1.10 2001/07/16 15:54:23 brianp Exp $ */ +/* $Id: imports.c,v 1.11 2002/06/13 04:28:29 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -31,8 +31,9 @@ * will call these functions in order to do memory allocation, simple I/O, * etc. * - * Some drivers will need to implement these functions themselves but - * many (most?) Mesa drivers will be fine using these. + * Some drivers will want to provide a specialed __GLimport object, but + * most Mesa drivers will be able to call _mesa_init_default_imports() + * and go with that. * * A server-side GL renderer will likely not use these functions since * the renderer should use the XFree86-wrapped system calls. @@ -119,8 +120,12 @@ _mesa_atoi(__GLcontext *gc, const char *str) static int CAPI _mesa_sprintf(__GLcontext *gc, char *str, const char *fmt, ...) { - /* XXX fix this */ - return sprintf(str, fmt); + int r; + va_list args; + va_start( args, fmt ); + r = vsprintf( str, fmt, args ); + va_end( args ); + return r; } static void * CAPI @@ -138,8 +143,12 @@ _mesa_fclose(__GLcontext *gc, void *stream) static int CAPI _mesa_fprintf(__GLcontext *gc, void *stream, const char *fmt, ...) { - /* XXX fix this */ - return fprintf((FILE *) stream, fmt); + int r; + va_list args; + va_start( args, fmt ); + r = vfprintf( (FILE *) stream, fmt, args ); + va_end( args ); + return r; } /* XXX this really is driver-specific and can't be here */ @@ -151,7 +160,7 @@ _mesa_GetDrawablePrivate(__GLcontext *gc) void -_mesa_InitDefaultImports(__GLimports *imports, void *driverCtx, void *other) +_mesa_init_default_imports(__GLimports *imports, void *driverCtx) { imports->malloc = _mesa_Malloc; imports->calloc = _mesa_Calloc; @@ -166,6 +175,5 @@ _mesa_InitDefaultImports(__GLimports *imports, void *driverCtx, void *other) imports->fclose = _mesa_fclose; imports->fprintf = _mesa_fprintf; imports->getDrawablePrivate = _mesa_GetDrawablePrivate; -/* imports->wscx = driverCtx; */ imports->other = driverCtx; } diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index cf4ca182b6..95bcf312a9 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -1,10 +1,10 @@ -/* $Id: imports.h,v 1.2 2001/03/12 00:48:38 gareth Exp $ */ +/* $Id: imports.h,v 1.3 2002/06/13 04:28:29 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -33,7 +33,7 @@ extern void -_mesa_InitDefaultImports(__GLimports *imports, void *driverCtx, void *other); +_mesa_init_default_imports(__GLimports *imports, void *driverCtx); #endif diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c index ee9d9d177e..b50eba7e9d 100644 --- a/src/mesa/main/light.c +++ b/src/mesa/main/light.c @@ -1,10 +1,10 @@ -/* $Id: light.c,v 1.49 2002/02/13 00:53:19 keithw Exp $ */ +/* $Id: light.c,v 1.50 2002/06/13 04:28:29 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -57,7 +57,7 @@ _mesa_ShadeModel( GLenum mode ) ASSERT_OUTSIDE_BEGIN_END(ctx); if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "glShadeModel %s\n", _mesa_lookup_enum_by_nr(mode)); + _mesa_debug("glShadeModel %s\n", _mesa_lookup_enum_by_nr(mode)); if (mode != GL_FLAT && mode != GL_SMOOTH) { _mesa_error( ctx, GL_INVALID_ENUM, "glShadeModel" ); @@ -617,7 +617,7 @@ void _mesa_update_material( GLcontext *ctx, bitmask &= ~ctx->Light.ColorMaterialBitmask; if (MESA_VERBOSE&VERBOSE_IMMEDIATE) - fprintf(stderr, "_mesa_update_material, mask 0x%x\n", bitmask); + _mesa_debug("_mesa_update_material, mask 0x%x\n", bitmask); if (!bitmask) return; @@ -717,19 +717,19 @@ void _mesa_update_material( GLcontext *ctx, if (0) { struct gl_material *mat = &ctx->Light.Material[0]; - fprintf(stderr, "update_mat emission : %f %f %f\n", + _mesa_debug("update_mat emission : %f %f %f\n", mat->Emission[0], mat->Emission[1], mat->Emission[2]); - fprintf(stderr, "update_mat specular : %f %f %f\n", + _mesa_debug("update_mat specular : %f %f %f\n", mat->Specular[0], mat->Specular[1], mat->Specular[2]); - fprintf(stderr, "update_mat diffuse : %f %f %f\n", + _mesa_debug("update_mat diffuse : %f %f %f\n", mat->Diffuse[0], mat->Diffuse[1], mat->Diffuse[2]); - fprintf(stderr, "update_mat ambient : %f %f %f\n", + _mesa_debug("update_mat ambient : %f %f %f\n", mat->Ambient[0], mat->Ambient[1], mat->Ambient[2]); @@ -754,7 +754,7 @@ void _mesa_update_color_material( GLcontext *ctx, GLuint bitmask = ctx->Light.ColorMaterialBitmask; if (MESA_VERBOSE&VERBOSE_IMMEDIATE) - fprintf(stderr, "_mesa_update_color_material, mask 0x%x\n", bitmask); + _mesa_debug("_mesa_update_color_material, mask 0x%x\n", bitmask); /* update emissive colors */ if (bitmask & FRONT_EMISSION_BIT) { @@ -834,19 +834,19 @@ void _mesa_update_color_material( GLcontext *ctx, if (0) { struct gl_material *mat = &ctx->Light.Material[0]; - fprintf(stderr, "update_color_mat emission : %f %f %f\n", + _mesa_debug("update_color_mat emission : %f %f %f\n", mat->Emission[0], mat->Emission[1], mat->Emission[2]); - fprintf(stderr, "update_color_mat specular : %f %f %f\n", + _mesa_debug("update_color_mat specular : %f %f %f\n", mat->Specular[0], mat->Specular[1], mat->Specular[2]); - fprintf(stderr, "update_color_mat diffuse : %f %f %f\n", + _mesa_debug("update_color_mat diffuse : %f %f %f\n", mat->Diffuse[0], mat->Diffuse[1], mat->Diffuse[2]); - fprintf(stderr, "update_color_mat ambient : %f %f %f\n", + _mesa_debug("update_color_mat ambient : %f %f %f\n", mat->Ambient[0], mat->Ambient[1], mat->Ambient[2]); @@ -868,7 +868,7 @@ _mesa_ColorMaterial( GLenum face, GLenum mode ) ASSERT_OUTSIDE_BEGIN_END(ctx); if (MESA_VERBOSE&VERBOSE_API) - fprintf(stderr, "glColorMaterial %s %s\n", + _mesa_debug("glColorMaterial %s %s\n", _mesa_lookup_enum_by_nr(face), _mesa_lookup_enum_by_nr(mode)); diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c index bef520a467..8ccd65b94d 100644 --- a/src/mesa/main/matrix.c +++ b/src/mesa/main/matrix.c @@ -1,10 +1,10 @@ -/* $Id: matrix.c,v 1.40 2002/04/22 20:00:16 alanh Exp $ */ +/* $Id: matrix.c,v 1.41 2002/06/13 04:28:29 brianp Exp $ */ /* * Mesa 3-D graphics library * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -157,7 +157,7 @@ _mesa_PushMatrix( void ) ASSERT_OUTSIDE_BEGIN_END(ctx); if (MESA_VERBOSE&VERBOSE_API) - fprintf(stderr, "glPushMatrix %s\n", + _mesa_debug("glPushMatrix %s\n", _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode)); if (stack->Depth + 1 >= stack->MaxDepth) { @@ -181,7 +181,7 @@ _mesa_PopMatrix( void ) ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); if (MESA_VERBOSE&VERBOSE_API) - fprintf(stderr, "glPopMatrix %s\n", + _mesa_debug("glPopMatrix %s\n", _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode)); if (stack->Depth == 0) { @@ -390,7 +390,7 @@ _mesa_set_viewport( GLcontext *ctx, GLint x, GLint y, } if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "glViewport %d %d %d %d\n", x, y, width, height); + _mesa_debug("glViewport %d %d %d %d\n", x, y, width, height); /* clamp width, and height to implementation dependent range */ width = CLAMP( width, 1, MAX_WIDTH ); @@ -446,7 +446,7 @@ _mesa_DepthRange( GLclampd nearval, GLclampd farval ) ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); if (MESA_VERBOSE&VERBOSE_API) - fprintf(stderr, "glDepthRange %f %f\n", nearval, farval); + _mesa_debug("glDepthRange %f %f\n", nearval, farval); n = (GLfloat) CLAMP( nearval, 0.0, 1.0 ); f = (GLfloat) CLAMP( farval, 0.0, 1.0 ); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index cc6c40f7a2..5c7d642ba8 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1,4 +1,4 @@ -/* $Id: mtypes.h,v 1.77 2002/06/06 16:31:24 brianp Exp $ */ +/* $Id: mtypes.h,v 1.78 2002/06/13 04:28:29 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -828,7 +828,7 @@ struct gl_texture_format { * GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA, * GL_COLOR_INDEX or GL_DEPTH_COMPONENT. */ - GLenum Type; /* Internal type as GL enum value */ + GLenum Type; /* Internal type as GL enum value - UNUSED?? */ GLubyte RedBits; /* Bits per texel component */ GLubyte GreenBits; @@ -1638,6 +1638,8 @@ struct gl_tnl_module { /** * This is the central context data structure for Mesa. Almost all * OpenGL state is contained in this structure. + * Think of this as a base class from which device drivers will derive + * sub classes. */ struct __GLcontextRec { /** -- cgit v1.2.3