diff options
author | Brian Paul <[email protected]> | 2002-06-13 04:28:29 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2002-06-13 04:28:29 +0000 |
commit | 9a33a11d714c90162d32781ebbd2c1dfab52cfd1 (patch) | |
tree | 00ec2c2fbe1ae59d732c34d2babd0ea7792d6b6a | |
parent | 1013e4650473ef0aceac7f3cd571b982ff249250 (diff) |
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)
33 files changed, 381 insertions, 192 deletions
diff --git a/src/mesa/Makefile.X11 b/src/mesa/Makefile.X11 index 8ab3a308499..19a90b03b23 100644 --- a/src/mesa/Makefile.X11 +++ b/src/mesa/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/drivers/allegro/amesa.c b/src/mesa/drivers/allegro/amesa.c index 2585c218d85..41dfcb18f08 100644 --- a/src/mesa/drivers/allegro/amesa.c +++ b/src/mesa/drivers/allegro/amesa.c @@ -22,6 +22,7 @@ #include <stdlib.h>
#include <allegro.h>
#include "context.h"
+#include "imports.h"
#include "matrix.h"
#include "mtypes.h" #include "GL/amesa.h"
@@ -325,11 +326,12 @@ void AMesaDestroyBuffer(AMesaBuffer buffer) AMesaContext AMesaCreateContext(AMesaVisual visual,
AMesaContext share)
- {
+{
AMesaContext context;
GLboolean direct = GL_FALSE;
+ __GLimports imports; - context = (AMesaContext)calloc(1, sizeof(struct amesa_context));
+ context = (AMesaContext)calloc(1, sizeof(struct amesa_context));
if (!context)
return NULL;
@@ -337,18 +339,18 @@ AMesaContext AMesaCreateContext(AMesaVisual visual, context->Buffer = NULL;
context->ClearColor = 0;
context->CurrentColor = 0;
- context->GLContext = _mesa_create_context(visual->GLVisual,
+ _mesa_init_default_imports( &imports, (void *) context); + context->GLContext = _mesa_create_context(visual->GLVisual,
share ? share->GLContext : NULL,
- (void*)context,
- direct);
- if (!context->GLContext)
+ &imports );
+ if (!context->GLContext)
{
- free(context);
- return NULL;
+ free(context);
+ return NULL;
}
return context;
- }
+}
void AMesaDestroyContext(AMesaContext context)
diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c index 559204fc53d..5ac7af42a00 100644 --- a/src/mesa/drivers/dos/dmesa.c +++ b/src/mesa/drivers/dos/dmesa.c @@ -38,6 +38,7 @@ #include "context.h"
#include "GL/dmesa.h"
#include "extensions.h"
+#inlcude "imports.h"
#include "macros.h"
#include "matrix.h"
#include "mmath.h"
@@ -839,9 +840,11 @@ DMesaContext DMesaCreateContext (DMesaVisual visual, GLboolean direct = GL_FALSE;
if ((c=(DMesaContext)calloc(1, sizeof(struct dmesa_context)))!=NULL) {
+ __GLimports imports;
+ _mesa_init_default_imports( &imports, (void *) c);
c->gl_ctx = _mesa_create_context(visual->gl_visual,
share ? share->gl_ctx : NULL,
- (void *)c, direct);
+ &imports);
_mesa_enable_sw_extensions(c->gl_ctx);
_mesa_enable_1_3_extensions(c->gl_ctx);
diff --git a/src/mesa/drivers/ggi/ggimesa.c b/src/mesa/drivers/ggi/ggimesa.c index a4621bb2889..339a7085908 100644 --- a/src/mesa/drivers/ggi/ggimesa.c +++ b/src/mesa/drivers/ggi/ggimesa.c @@ -30,6 +30,7 @@ #include <ggi/mesa/ggimesa_int.h> #include <ggi/mesa/debug.h> #include "extensions.h" +#include "imports.h" #include "matrix.h" #include "swrast/swrast.h" #include "swrast_setup/swrast_setup.h" @@ -470,6 +471,7 @@ ggi_mesa_context_t ggiMesaCreateContext(ggi_visual_t vis) int err; ggi_color pal[256]; int i; + __GLimports imports; GGIMESADPRINT_CORE("ggiMesaCreateContext() called\n"); @@ -480,9 +482,10 @@ ggi_mesa_context_t ggiMesaCreateContext(ggi_visual_t vis) ctx->ggi_visual = vis; ctx->color = 0; + _mesa_init_default_imports( &imports, (void *) ctx); ctx->gl_ctx = _mesa_create_context(&(LIBGGI_MESAEXT(vis)->mesa_visual.gl_visual), - NULL, (void *)ctx, GL_TRUE); + NULL, &imports); if (!ctx->gl_ctx) goto free_context; @@ -509,8 +512,6 @@ ggi_mesa_context_t ggiMesaCreateContext(ggi_visual_t vis) goto free_gl_context; } - _mesa_read_config_file(ctx->gl_ctx); - return ctx; free_gl_context: diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c index 8cdbe35382a..a5541eceb1d 100644 --- a/src/mesa/drivers/glide/fxdd.c +++ b/src/mesa/drivers/glide/fxdd.c @@ -1,4 +1,4 @@ -/* $Id: fxdd.c,v 1.85 2002/03/16 00:53:15 brianp Exp $ */ +/* $Id: fxdd.c,v 1.86 2002/06/13 04:28:30 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -766,9 +766,6 @@ fxDDInitFxMesaContext(fxMesaContext fxMesa) FX_grGlideGetState((GrState *) fxMesa->state); - /* Run the config file */ - _mesa_read_config_file(fxMesa->glCtx); - return 1; } diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h index f3f6fa4c9b8..27e4f146b9c 100644 --- a/src/mesa/drivers/glide/fxdrv.h +++ b/src/mesa/drivers/glide/fxdrv.h @@ -1,4 +1,4 @@ -/* $Id: fxdrv.h,v 1.52 2001/09/23 16:50:01 brianp Exp $ */ +/* $Id: fxdrv.h,v 1.53 2002/06/13 04:28:30 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -49,6 +49,7 @@ #endif #include "context.h" +#include "imports.h" #include "macros.h" #include "matrix.h" #include "mem.h" diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index 9dc08b58206..1a5cefea087 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -1,4 +1,4 @@ -/* $Id: osmesa.c,v 1.79 2002/04/19 14:05:51 brianp Exp $ */ +/* $Id: osmesa.c,v 1.80 2002/06/13 04:28:30 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -42,6 +42,7 @@ #include "colormac.h" #include "depth.h" #include "extensions.h" +#include "imports.h" #include "macros.h" #include "matrix.h" #include "mem.h" @@ -138,6 +139,7 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits, const GLuint i4 = 1; const GLubyte *i1 = (GLubyte *) &i4; const GLint little_endian = *i1; + __GLimports imports; rind = gind = bind = aind = 0; if (format==OSMESA_COLOR_INDEX) { @@ -290,11 +292,12 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits, return NULL; } + _mesa_init_default_imports( &imports, (void *) osmesa ); if (!_mesa_initialize_context(&osmesa->gl_ctx, osmesa->gl_visual, sharelist ? &sharelist->gl_ctx : (GLcontext *) NULL, - (void *) osmesa, GL_TRUE )) { + &imports)) { _mesa_destroy_visual( osmesa->gl_visual ); FREE(osmesa); return NULL; diff --git a/src/mesa/drivers/svga/svgamesa.c b/src/mesa/drivers/svga/svgamesa.c index c841f46f012..7e8f81083cf 100644 --- a/src/mesa/drivers/svga/svgamesa.c +++ b/src/mesa/drivers/svga/svgamesa.c @@ -1,4 +1,4 @@ -/* $Id: svgamesa.c,v 1.17 2002/03/16 00:53:15 brianp Exp $ */ +/* $Id: svgamesa.c,v 1.18 2002/06/13 04:28:30 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -44,6 +44,7 @@ #include "GL/svgamesa.h" #include "context.h" #include "extensions.h" +#include "imports.h" #include "matrix.h" #include "mtypes.h" #include "swrast/swrast.h" @@ -378,6 +379,8 @@ SVGAMesaContext SVGAMesaCreateContext( GLboolean doubleBuffer ) GLfloat redscale, greenscale, bluescale, alphascale; GLint index_bits; GLint redbits, greenbits, bluebits, alphabits; + __GLimports imports; + /* determine if we're in RGB or color index mode */ if ((SVGABuffer.Depth==32) || (SVGABuffer.Depth==24)) { rgb_flag = GL_TRUE; @@ -426,9 +429,10 @@ SVGAMesaContext SVGAMesaCreateContext( GLboolean doubleBuffer ) 1 /* samples */ ); + _mesa_init_default_imports( &imports, (void *) ctx); ctx->gl_ctx = _mesa_create_context( ctx->gl_vis, NULL, /* share list context */ - (void *) ctx, GL_TRUE ); + &imports ); _mesa_enable_sw_extensions(ctx->gl_ctx); _mesa_enable_1_3_extensions(ctx->gl_ctx); diff --git a/src/mesa/drivers/windows/wmesa.c b/src/mesa/drivers/windows/wmesa.c index f7d47247d67..b973264cfb6 100644 --- a/src/mesa/drivers/windows/wmesa.c +++ b/src/mesa/drivers/windows/wmesa.c @@ -1,4 +1,4 @@ -/* $Id: wmesa.c,v 1.28 2002/04/23 18:39:09 kschultz Exp $ */ +/* $Id: wmesa.c,v 1.29 2002/06/13 04:28:30 brianp Exp $ */ /* * Windows (Win32) device driver for Mesa 3.4 @@ -36,6 +36,7 @@ #include "dd.h" #include "depth.h" #include "extensions.h" +#include "imports.h" #include "macros.h" #include "matrix.h" #include "mem.h" @@ -1253,6 +1254,8 @@ WMesaContext WMesaCreateContext( HWND hWnd, HPALETTE* Pal, RECT CR; WMesaContext c; GLboolean true_color_flag; + __GLimports imports; + c = (struct wmesa_context * ) calloc(1,sizeof(struct wmesa_context)); if (!c) return NULL; @@ -1339,8 +1342,10 @@ WMesaContext WMesaCreateContext( HWND hWnd, HPALETTE* Pal, return NULL; } + _mesa_init_default_imports( &imports, (void *) c ); + /* allocate a new Mesa context */ - c->gl_ctx = _mesa_create_context( c->gl_visual, NULL, c, GL_TRUE); + c->gl_ctx = _mesa_create_context( c->gl_visual, NULL, &imports ); if (!c->gl_ctx) { _mesa_destroy_visual( c->gl_visual ); diff --git a/src/mesa/drivers/windows/wmesa_stereo.c b/src/mesa/drivers/windows/wmesa_stereo.c index 385f30b1b1f..a4397c41bf1 100644 --- a/src/mesa/drivers/windows/wmesa_stereo.c +++ b/src/mesa/drivers/windows/wmesa_stereo.c @@ -17,6 +17,7 @@ #include <GL\wmesa.h>
#include "context.h"
#include "dd.h"
+#include "imports.h"
#include "xform.h"
#include "vb.h"
#include "matrix.h"
@@ -1110,6 +1111,7 @@ WMesaContext /*APIENTRY*/ WMesaCreateContext( HWND hWnd, HPALETTE Pal, //HDC DC;
RECT CR;
WMesaContext c;
+ __GLimports imports;
c = (struct wmesa_context * ) calloc(1,sizeof(struct wmesa_context));
if (!c)
@@ -1196,7 +1198,8 @@ WMesaContext /*APIENTRY*/ WMesaCreateContext( HWND hWnd, HPALETTE Pal, }
/* allocate a new Mesa context */
- c->gl_ctx = _mesa_create_context( c->gl_visual, NULL,c);
+ _mesa_init_default_imports( &imports, (void *) c );
+ c->gl_ctx = _mesa_create_context( c->gl_visual, &imports );
if (!c->gl_ctx) {
_mesa_destroy_visual( c->gl_visual );
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index d155f145b8e..46e7454b971 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -1,4 +1,4 @@ -/* $Id: xm_api.c,v 1.36 2002/05/27 17:06:59 brianp Exp $ */ +/* $Id: xm_api.c,v 1.37 2002/06/13 04:28:30 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -69,6 +69,7 @@ #include "context.h" #include "extensions.h" #include "glthread.h" +#include "imports.h" #include "matrix.h" #include "mem.h" #include "mmath.h" @@ -1618,11 +1619,10 @@ void XMesaDestroyVisual( XMesaVisual v ) */ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) { + static GLboolean firstTime = GL_TRUE; XMesaContext c; GLcontext *ctx; - GLboolean direct = GL_TRUE; /* XXXX */ - /* NOT_DONE: should this be GL_FALSE??? */ - static GLboolean firstTime = GL_TRUE; + __GLimports imports; if (firstTime) { _glthread_INIT_MUTEX(_xmesa_lock); @@ -1634,9 +1634,10 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) return NULL; } + _mesa_init_default_imports( &imports, (void *) c ); ctx = c->gl_ctx = _mesa_create_context( &v->mesa_visual, share_list ? share_list->gl_ctx : (GLcontext *) NULL, - (void *) c, direct ); + &imports ); if (!c->gl_ctx) { FREE(c); return NULL; @@ -1672,12 +1673,6 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) */ xmesa_init_pointers( ctx ); - - /* Run the config file - */ - _mesa_read_config_file( ctx ); - - return c; } diff --git a/src/mesa/main/Makefile.DJ b/src/mesa/main/Makefile.DJ index afe95f0c367..4749bfd849d 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 eeb32a264b6..4613f1a2703 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 8ab3a308499..19a90b03b23 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 92ca94c9f27..f8f00fa411b 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 a536d1e4ea1..77814140a71 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 b75fe4d6259..f5f611784b8 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 b00e834d4f2..6d5b6a13f55 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 e1706c32553..295921e1d0b 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 420bfa46914..bb436590636 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; } @@ -148,12 +277,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 ) { @@ -1918,6 +2036,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 e0bb2ad09f6..49555ff6e2c 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 36daf5c5920..3c25550e948 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 3ae3f67bc14..6b67b31675d 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 87db3d5a6f2..5d29149ca06 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 fcd87146524..94ed866fdc2 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 0705f884e68..5770db95333 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 3a66f618a20..8a9cf4b82b1 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 <stdarg.h> /* 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 e37cfb1a87d..d75823feb9e 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 61fbf609157..b4e5dca930a 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 cf4ca182b68..95bcf312a97 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 ee9d9d177e8..b50eba7e9d0 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 bef520a4679..8ccd65b94d0 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 cc6c40f7a23..5c7d642ba84 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 { /** |