summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/api_arrayelt.c4
-rw-r--r--src/mesa/main/attrib.c9
-rw-r--r--src/mesa/main/blend.c24
-rw-r--r--src/mesa/main/buffers.c30
-rw-r--r--src/mesa/main/config.h4
-rw-r--r--src/mesa/main/context.c101
-rw-r--r--src/mesa/main/context.h7
-rw-r--r--src/mesa/main/dd.h15
-rw-r--r--src/mesa/main/depth.c6
-rw-r--r--src/mesa/main/dlist.c141
-rw-r--r--src/mesa/main/drawpix.c67
-rw-r--r--src/mesa/main/enable.c4
-rw-r--r--src/mesa/main/get.c14
-rw-r--r--src/mesa/main/glheader.h18
-rw-r--r--src/mesa/main/hint.c34
-rw-r--r--src/mesa/main/hint.h9
-rw-r--r--src/mesa/main/imports.c14
-rw-r--r--src/mesa/main/light.c68
-rw-r--r--src/mesa/main/matrix.c14
-rw-r--r--src/mesa/main/mtypes.h11
-rw-r--r--src/mesa/main/polygon.c14
-rw-r--r--src/mesa/main/texformat.c153
-rw-r--r--src/mesa/main/texformat.h11
-rw-r--r--src/mesa/main/texformat_tmp.h94
-rw-r--r--src/mesa/main/texobj.c4
-rw-r--r--src/mesa/main/texstate.c10
-rw-r--r--src/mesa/main/varray.c30
27 files changed, 616 insertions, 294 deletions
diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c
index acca5701a53..0a39ecdefb9 100644
--- a/src/mesa/main/api_arrayelt.c
+++ b/src/mesa/main/api_arrayelt.c
@@ -1,4 +1,4 @@
-/* $Id: api_arrayelt.c,v 1.8 2002/04/19 00:23:08 brianp Exp $ */
+/* $Id: api_arrayelt.c,v 1.9 2002/06/15 02:38:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -347,7 +347,7 @@ void _ae_loopback_array_elt( GLint elt )
_ae_update_state( ctx );
for (ta = actx->texarrays ; ta->func ; ta++) {
- ta->func( ta->unit, (char *)ta->array->Ptr + elt * ta->array->StrideB );
+ ta->func( ta->unit + GL_TEXTURE0_ARB, (char *)ta->array->Ptr + elt * ta->array->StrideB );
}
/* Must be last
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index f5f611784b8..a7f90155bb6 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1,4 +1,4 @@
-/* $Id: attrib.c,v 1.66 2002/06/13 04:28:29 brianp Exp $ */
+/* $Id: attrib.c,v 1.67 2002/06/15 02:38:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -120,7 +120,7 @@ _mesa_PushAttrib(GLbitfield mask)
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug("glPushAttrib %x\n", (int) mask);
+ _mesa_debug(ctx, "glPushAttrib %x\n", (int) mask);
if (ctx->AttribStackDepth >= MAX_ATTRIB_STACK_DEPTH) {
_mesa_error( ctx, GL_STACK_OVERFLOW, "glPushAttrib" );
@@ -802,7 +802,8 @@ _mesa_PopAttrib(void)
while (attr) {
if (MESA_VERBOSE & VERBOSE_API) {
- _mesa_debug("glPopAttrib %s\n", _mesa_lookup_enum_by_nr(attr->kind));
+ _mesa_debug(ctx, "glPopAttrib %s\n",
+ _mesa_lookup_enum_by_nr(attr->kind));
}
switch (attr->kind) {
@@ -1078,7 +1079,7 @@ _mesa_PopAttrib(void)
_mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_FALSE);
}
if (ctx->Driver.ClipPlane)
- ctx->Driver.ClipPlane( ctx, i, eyePlane );
+ ctx->Driver.ClipPlane( ctx, GL_CLIP_PLANE0 + i, eyePlane );
}
/* normalize/rescale */
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index 6d5b6a13f55..97b11872c42 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -1,4 +1,4 @@
-/* $Id: blend.c,v 1.35 2002/06/13 04:28:29 brianp Exp $ */
+/* $Id: blend.c,v 1.36 2002/06/15 02:38:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -46,9 +46,9 @@ _mesa_BlendFunc( GLenum sfactor, GLenum dfactor )
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
- _mesa_debug("glBlendFunc %s %s\n",
- _mesa_lookup_enum_by_nr(sfactor),
- _mesa_lookup_enum_by_nr(dfactor));
+ _mesa_debug(ctx, "glBlendFunc %s %s\n",
+ _mesa_lookup_enum_by_nr(sfactor),
+ _mesa_lookup_enum_by_nr(dfactor));
switch (sfactor) {
case GL_SRC_COLOR:
@@ -127,11 +127,11 @@ _mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB,
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
- _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),
- _mesa_lookup_enum_by_nr(dfactorA));
+ _mesa_debug(ctx, "glBlendFuncSeparate %s %s %s %s\n",
+ _mesa_lookup_enum_by_nr(sfactorRGB),
+ _mesa_lookup_enum_by_nr(dfactorRGB),
+ _mesa_lookup_enum_by_nr(sfactorA),
+ _mesa_lookup_enum_by_nr(dfactorA));
switch (sfactorRGB) {
case GL_SRC_COLOR:
@@ -268,8 +268,8 @@ _mesa_BlendEquation( GLenum mode )
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
- _mesa_debug("glBlendEquation %s\n",
- _mesa_lookup_enum_by_nr(mode));
+ _mesa_debug(ctx, "glBlendEquation %s\n",
+ _mesa_lookup_enum_by_nr(mode));
switch (mode) {
case GL_FUNC_ADD_EXT:
@@ -445,7 +445,7 @@ _mesa_ColorMask( GLboolean red, GLboolean green,
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug("glColorMask %d %d %d %d\n", red, green, blue, alpha);
+ _mesa_debug(ctx, "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 295921e1d0b..c549e2736c4 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -1,4 +1,4 @@
-/* $Id: buffers.c,v 1.35 2002/06/13 04:28:29 brianp Exp $ */
+/* $Id: buffers.c,v 1.36 2002/06/15 02:38:15 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)
- _mesa_debug("glClear 0x%x\n", mask);
+ _mesa_debug(ctx, "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)
- _mesa_debug("glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(mode));
+ _mesa_debug(ctx, "glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(mode));
switch (mode) {
case GL_AUX0:
@@ -267,23 +267,11 @@ _mesa_DrawBuffer( GLenum mode )
}
/*
- * If we get here there can't have been an error.
- * Now see if device driver can implement the drawing to the target
- * buffer(s). The driver may not be able to do GL_FRONT_AND_BACK mode
- * for example. We'll take care of that in the core code by looping
- * over the individual buffers.
+ * If we get here there can't have been an error. Now tell the
+ * device driver about it.
*/
ASSERT(ctx->Driver.SetDrawBuffer);
- if ( (*ctx->Driver.SetDrawBuffer)(ctx, ctx->Color.DriverDrawBuffer) ) {
- /* All OK, the driver will do all buffer writes */
- ctx->Color.MultiDrawBuffer = GL_FALSE;
- }
- else {
- /* We'll have to loop over the multiple draw buffer targets */
- ctx->Color.MultiDrawBuffer = GL_TRUE;
- /* Set drawing buffer to front for now */
- (void) (*ctx->Driver.SetDrawBuffer)(ctx, GL_FRONT_LEFT);
- }
+ (*ctx->Driver.SetDrawBuffer)(ctx, ctx->Color.DriverDrawBuffer);
ctx->Color.DrawBuffer = mode;
ctx->NewState |= _NEW_COLOR;
@@ -298,7 +286,7 @@ _mesa_ReadBuffer( GLenum mode )
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug("glReadBuffer %s\n", _mesa_lookup_enum_by_nr(mode));
+ _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(mode));
switch (mode) {
case GL_AUX0:
@@ -360,7 +348,7 @@ _mesa_ResizeBuffersMESA( void )
GLcontext *ctx = _mesa_get_current_context();
if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug("glResizeBuffersMESA\n");
+ _mesa_debug(ctx, "glResizeBuffersMESA\n");
if (ctx) {
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx );
@@ -416,7 +404,7 @@ _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
}
if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug("glScissor %d %d %d %d\n", x, y, width, height);
+ _mesa_debug(ctx, "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/config.h b/src/mesa/main/config.h
index 96dafac0ade..d02baedcc94 100644
--- a/src/mesa/main/config.h
+++ b/src/mesa/main/config.h
@@ -1,4 +1,4 @@
-/* $Id: config.h,v 1.38 2002/05/27 17:04:52 brianp Exp $ */
+/* $Id: config.h,v 1.39 2002/06/15 02:38:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -151,7 +151,7 @@
/*
* Bits per accumulation buffer color component: 8, 16 or 32
*/
-#define ACCUM_BITS 16
+#define ACCUM_BITS 32
/*
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index a1975bd00ca..2baff7c2990 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.166 2002/06/13 04:49:17 brianp Exp $ */
+/* $Id: context.c,v 1.167 2002/06/15 02:38:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -232,12 +232,13 @@ __glCoreCreateContext(__GLimports *imports, __GLcontextModes *modes)
{
GLcontext *ctx;
- ctx = (GLcontext *) (*imports->calloc)(0, 1, sizeof(GLcontext));
+ ctx = (GLcontext *) (*imports->calloc)(NULL, 1, sizeof(GLcontext));
if (ctx == NULL) {
return NULL;
}
ctx->Driver.CurrentExecPrimitive=0; /* XXX why is this here??? */
ctx->imports = *imports;
+ _mesa_init_default_exports(&(ctx->exports));
_mesa_initialize_visual(&ctx->Visual,
modes->rgbMode,
@@ -552,7 +553,7 @@ _glthread_DECLARE_STATIC_MUTEX(OneTimeLock);
* This function just calls all the various one-time-init functions in Mesa.
*/
static void
-one_time_init( void )
+one_time_init( GLcontext *ctx )
{
static GLboolean alreadyCalled = GL_FALSE;
_glthread_LOCK_MUTEX(OneTimeLock);
@@ -573,7 +574,7 @@ one_time_init( void )
#ifdef USE_SPARC_ASM
_mesa_init_sparc_glapi_relocs();
#endif
- if (getenv("MESA_DEBUG")) {
+ if (ctx->imports.getenv(ctx, "MESA_DEBUG")) {
_glapi_noop_enable_warnings(GL_TRUE);
}
else {
@@ -581,7 +582,7 @@ one_time_init( void )
}
#if defined(DEBUG) && defined(__DATE__) && defined(__TIME__)
- fprintf(stderr, "Mesa DEBUG build %s %s\n", __DATE__, __TIME__);
+ fprintf(stderr, "Mesa DEBUG build %s %s\n", __DATE__, __TIME__);
#endif
alreadyCalled = GL_TRUE;
@@ -1456,13 +1457,13 @@ init_attrib_groups( GLcontext *ctx )
ctx->OcclusionResultSaved = GL_FALSE;
/* For debug/development only */
- ctx->NoRaster = getenv("MESA_NO_RASTER") ? GL_TRUE : GL_FALSE;
+ ctx->NoRaster = ctx->imports.getenv(ctx, "MESA_NO_RASTER") ? GL_TRUE : GL_FALSE;
ctx->FirstTimeCurrent = GL_TRUE;
/* Dither disable */
- ctx->NoDither = getenv("MESA_NO_DITHER") ? GL_TRUE : GL_FALSE;
+ ctx->NoDither = ctx->imports.getenv(ctx, "MESA_NO_DITHER") ? GL_TRUE : GL_FALSE;
if (ctx->NoDither) {
- if (getenv("MESA_DEBUG")) {
+ if (ctx->imports.getenv(ctx, "MESA_DEBUG")) {
fprintf(stderr, "MESA_NO_DITHER set - dithering disabled\n");
}
ctx->Color.DitherFlag = GL_FALSE;
@@ -1602,11 +1603,14 @@ _mesa_initialize_context( GLcontext *ctx,
ASSERT(imports);
ASSERT(imports->other); /* other points to the device driver's context */
- /* misc one-time initializations */
- one_time_init();
+ /* assing imports */
+ ctx->imports = *imports;
/* initialize the exports (Mesa functions called by the window system) */
- _mesa_init_default_exports( &(ctx->exports) );
+ _mesa_init_default_exports( &(ctx->exports) );
+
+ /* misc one-time initializations */
+ one_time_init(ctx);
#if 0
/**
@@ -1756,11 +1760,11 @@ _mesa_initialize_context( GLcontext *ctx,
#endif
- if (getenv("MESA_DEBUG"))
- add_debug_flags(getenv("MESA_DEBUG"));
+ if (ctx->imports.getenv(ctx, "MESA_DEBUG"))
+ add_debug_flags(ctx->imports.getenv(ctx, "MESA_DEBUG"));
- if (getenv("MESA_VERBOSE"))
- add_debug_flags(getenv("MESA_VERBOSE"));
+ if (ctx->imports.getenv(ctx, "MESA_VERBOSE"))
+ add_debug_flags(ctx->imports.getenv(ctx, "MESA_VERBOSE"));
return GL_TRUE;
}
@@ -1779,16 +1783,23 @@ _mesa_create_context( const GLvisual *visual,
GLcontext *share_list,
const __GLimports *imports )
{
- GLcontext *ctx = (GLcontext *) CALLOC( sizeof(GLcontext) );
- if (!ctx) {
+ GLcontext *ctx;
+
+ ASSERT(visual);
+ ASSERT(imports);
+ ASSERT(imports->calloc);
+
+ ctx = (GLcontext *) imports->calloc(NULL, 1, sizeof(GLcontext));
+ if (!ctx)
return NULL;
- }
+
ctx->Driver.CurrentExecPrimitive = 0; /* XXX why is this here??? */
+
if (_mesa_initialize_context(ctx, visual, share_list, imports)) {
return ctx;
}
else {
- FREE(ctx);
+ imports->free(NULL, ctx);
return NULL;
}
}
@@ -2054,7 +2065,7 @@ _mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
GLframebuffer *readBuffer )
{
if (MESA_VERBOSE)
- fprintf(stderr, "_mesa_make_current2()\n");
+ _mesa_debug(newCtx, "_mesa_make_current2()\n");
/* Check that the context's and framebuffer's visuals are compatible.
* We could do a lot more checking here but this'll catch obvious
@@ -2102,7 +2113,7 @@ _mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
* information.
*/
if (newCtx->FirstTimeCurrent) {
- if (getenv("MESA_INFO")) {
+ if (newCtx->imports.getenv(newCtx, "MESA_INFO")) {
print_info();
}
newCtx->FirstTimeCurrent = GL_FALSE;
@@ -2162,13 +2173,23 @@ _mesa_get_dispatch(GLcontext *ctx)
*/
void _mesa_problem( const GLcontext *ctx, const char *s )
{
- fprintf( stderr, "Mesa implementation error: %s\n", s );
+ if (ctx) {
+ ctx->imports.fprintf((GLcontext *) ctx, stderr, "Mesa implementation error: %s\n", s);
+#ifdef XF86DRI
+ ctx->imports.fprintf((GLcontext *) ctx, stderr, "Please report to the DRI bug database at dri.sourceforge.net\n");
+#else
+ ctx->imports.fprintf((GLcontext *) ctx, stderr, "Please report to the Mesa bug database at www.mesa3d.org\n" );
+#endif
+ }
+ else {
+ /* what can we do if we don't have a context???? */
+ fprintf( stderr, "Mesa implementation error: %s\n", s );
#ifdef XF86DRI
- fprintf( stderr, "Please report to the DRI bug database at dri.sourceforge.net\n");
+ fprintf( stderr, "Please report to the DRI bug database at dri.sourceforge.net\n");
#else
- fprintf( stderr, "Please report to the Mesa bug database at www.mesa3d.org\n" );
+ fprintf( stderr, "Please report to the Mesa bug database at www.mesa3d.org\n" );
#endif
- (void) ctx;
+ }
}
@@ -2198,9 +2219,15 @@ _mesa_warning( const GLcontext *ctx, const char *s )
void
_mesa_error( GLcontext *ctx, GLenum error, const char *where )
{
- const char *debugEnv = getenv("MESA_DEBUG");
+ const char *debugEnv;
GLboolean debug;
+ if (ctx)
+ debugEnv = ctx->imports.getenv(ctx, "MESA_DEBUG");
+ else
+ /* what can we do??? */
+ debugEnv = "";
+
#ifdef DEBUG
if (debugEnv && strstr(debugEnv, "silent"))
debug = GL_FALSE;
@@ -2262,20 +2289,32 @@ _mesa_error( GLcontext *ctx, GLenum error, const char *where )
/*
- * Call this to report debug information.
+ * Call this to report debug information. Uses stderr.
*/
void
-_mesa_debug( const char *fmtString, ... )
+_mesa_debug( const GLcontext *ctx, const char *fmtString, ... )
{
-#ifdef DEBUG
va_list args;
va_start( args, fmtString );
- (void) vfprintf( stderr, fmtString, args );
+ (void) ctx->imports.fprintf( (__GLcontext *) ctx, stderr, fmtString, args );
+ va_end( args );
+}
+
+
+/*
+ * A wrapper for printf. Uses stdout.
+ */
+void
+_mesa_printf( const GLcontext *ctx, const char *fmtString, ... )
+{
+ va_list args;
+ va_start( args, fmtString );
+ (void) ctx->imports.fprintf( (__GLcontext *) ctx, stdout, 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 23cd7e11047..8e9524fec58 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -1,4 +1,4 @@
-/* $Id: context.h,v 1.31 2002/06/13 04:49:17 brianp Exp $ */
+/* $Id: context.h,v 1.32 2002/06/15 02:38:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -238,7 +238,10 @@ extern void
_mesa_error( GLcontext *ctx, GLenum error, const char *s );
extern void
-_mesa_debug( const char *fmtString, ... );
+_mesa_debug( const GLcontext *ctx, const char *fmtString, ... );
+
+extern void
+_mesa_printf( const GLcontext *ctx, const char *fmtString, ... );
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 25b72245e40..1a100102ae4 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1,10 +1,10 @@
-/* $Id: dd.h,v 1.68 2002/04/21 18:49:18 brianp Exp $ */
+/* $Id: dd.h,v 1.69 2002/06/15 02:38:15 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"),
@@ -77,7 +77,7 @@ struct dd_function_table {
* settings! Software Mesa can do masked clears if the device driver can't.
*/
- GLboolean (*SetDrawBuffer)( GLcontext *ctx, GLenum buffer );
+ void (*SetDrawBuffer)( GLcontext *ctx, GLenum buffer );
/*
* Specifies the current buffer for writing.
* The following values must be accepted when applicable:
@@ -85,16 +85,15 @@ struct dd_function_table {
* GL_BACK_LEFT - when double buffering
* GL_FRONT_RIGHT - when using stereo
* GL_BACK_RIGHT - when using stereo and double buffering
- * The folowing values may optionally be accepted. Return GL_TRUE
- * if accepted, GL_FALSE if not accepted. In practice, only drivers
- * which can write to multiple color buffers at once should accept
- * these values.
* GL_FRONT - write to front left and front right if it exists
* GL_BACK - write to back left and back right if it exists
* GL_LEFT - write to front left and back left if it exists
* GL_RIGHT - write to right left and back right if they exist
* GL_FRONT_AND_BACK - write to all four buffers if they exist
* GL_NONE - disable buffer write in device driver.
+ *
+ * Note the driver must organize fallbacks (eg with swrast) if it
+ * cannot implement the requested mode.
*/
void (*GetBufferSize)( GLframebuffer *buffer,
diff --git a/src/mesa/main/depth.c b/src/mesa/main/depth.c
index 3c25550e948..1ae912529bb 100644
--- a/src/mesa/main/depth.c
+++ b/src/mesa/main/depth.c
@@ -1,4 +1,4 @@
-/* $Id: depth.c,v 1.29 2002/06/13 04:28:29 brianp Exp $ */
+/* $Id: depth.c,v 1.30 2002/06/15 02:38:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -70,7 +70,7 @@ _mesa_DepthFunc( GLenum func )
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
- _mesa_debug("glDepthFunc %s\n", _mesa_lookup_enum_by_nr(func));
+ _mesa_debug(ctx, "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))
- _mesa_debug("glDepthMask %d\n", flag);
+ _mesa_debug(ctx, "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 6b67b31675d..3523db550a2 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -1,4 +1,4 @@
-/* $Id: dlist.c,v 1.89 2002/06/13 04:28:29 brianp Exp $ */
+/* $Id: dlist.c,v 1.90 2002/06/15 02:38:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -4145,9 +4145,6 @@ execute_list( GLcontext *ctx, GLuint list )
if (ctx->Driver.BeginCallList)
ctx->Driver.BeginCallList( ctx, list );
-/* _mesa_debug("execute list %d\n", list); */
-/* mesa_print_display_list( list ); */
-
ctx->CallDepth++;
n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
@@ -4936,7 +4933,8 @@ _mesa_NewList( GLuint list, GLenum mode )
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE&VERBOSE_API)
- _mesa_debug("glNewList %u %s\n", list, _mesa_lookup_enum_by_nr(mode));
+ _mesa_debug(ctx, "glNewList %u %s\n", list,
+ _mesa_lookup_enum_by_nr(mode));
if (list==0) {
_mesa_error( ctx, GL_INVALID_VALUE, "glNewList" );
@@ -4983,7 +4981,7 @@ _mesa_EndList( void )
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
if (MESA_VERBOSE&VERBOSE_API)
- _mesa_debug("glEndList\n");
+ _mesa_debug(ctx, "glEndList\n");
/* Check that a list is under construction */
if (!ctx->CurrentListPtr) {
@@ -5026,7 +5024,7 @@ _mesa_CallList( GLuint list )
if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug("_mesa_CallList %d\n", list);
+ _mesa_debug(ctx, "_mesa_CallList %d\n", list);
/* mesa_print_display_list( list ); */
@@ -5059,7 +5057,7 @@ _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
GLboolean save_compile_flag;
if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug("_mesa_CallLists %d\n", n);
+ _mesa_debug(ctx, "_mesa_CallLists %d\n", n);
/* Save the CompileFlag status, turn it off, execute display list,
* and restore the CompileFlag.
@@ -6162,19 +6160,19 @@ static const char *enum_string( GLenum k )
* Print the commands in a display list. For debugging only.
* TODO: many commands aren't handled yet.
*/
-static void print_list( GLcontext *ctx, FILE *f, GLuint list )
+static void print_list( GLcontext *ctx, GLuint list )
{
Node *n;
GLboolean done;
if (!glIsList(list)) {
- fprintf(f,"%u is not a display list ID\n",list);
+ _mesa_printf(ctx, "%u is not a display list ID\n", list);
return;
}
n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
- fprintf( f, "START-LIST %u, address %p\n", list, (void*)n );
+ _mesa_printf(ctx, "START-LIST %u, address %p\n", list, (void*)n );
done = n ? GL_FALSE : GL_TRUE;
while (!done) {
@@ -6188,149 +6186,164 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list )
else {
switch (opcode) {
case OPCODE_ACCUM:
- fprintf(f,"accum %s %g\n", enum_string(n[1].e), n[2].f );
+ _mesa_printf(ctx, "accum %s %g\n", enum_string(n[1].e), n[2].f );
break;
case OPCODE_BITMAP:
- fprintf(f,"Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
+ _mesa_printf(ctx, "Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data );
break;
case OPCODE_CALL_LIST:
- fprintf(f,"CallList %d\n", (int) n[1].ui );
+ _mesa_printf(ctx, "CallList %d\n", (int) n[1].ui );
break;
case OPCODE_CALL_LIST_OFFSET:
- fprintf(f,"CallList %d + offset %u = %u\n", (int) n[1].ui,
+ _mesa_printf(ctx, "CallList %d + offset %u = %u\n", (int) n[1].ui,
ctx->List.ListBase, ctx->List.ListBase + n[1].ui );
break;
case OPCODE_COLOR_TABLE_PARAMETER_FV:
- fprintf(f,"ColorTableParameterfv %s %s %f %f %f %f\n",
+ _mesa_printf(ctx, "ColorTableParameterfv %s %s %f %f %f %f\n",
enum_string(n[1].e), enum_string(n[2].e),
n[3].f, n[4].f, n[5].f, n[6].f);
break;
case OPCODE_COLOR_TABLE_PARAMETER_IV:
- fprintf(f,"ColorTableParameteriv %s %s %d %d %d %d\n",
+ _mesa_printf(ctx, "ColorTableParameteriv %s %s %d %d %d %d\n",
enum_string(n[1].e), enum_string(n[2].e),
n[3].i, n[4].i, n[5].i, n[6].i);
break;
case OPCODE_DISABLE:
- fprintf(f,"Disable %s\n", enum_string(n[1].e));
+ _mesa_printf(ctx, "Disable %s\n", enum_string(n[1].e));
break;
case OPCODE_ENABLE:
- fprintf(f,"Enable %s\n", enum_string(n[1].e));
+ _mesa_printf(ctx, "Enable %s\n", enum_string(n[1].e));
break;
case OPCODE_FRUSTUM:
- fprintf(f,"Frustum %g %g %g %g %g %g\n",
+ _mesa_printf(ctx, "Frustum %g %g %g %g %g %g\n",
n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
break;
case OPCODE_LINE_STIPPLE:
- fprintf(f,"LineStipple %d %x\n", n[1].i, (int) n[2].us );
+ _mesa_printf(ctx, "LineStipple %d %x\n", n[1].i, (int) n[2].us );
break;
case OPCODE_LOAD_IDENTITY:
- fprintf(f,"LoadIdentity\n");
+ _mesa_printf(ctx, "LoadIdentity\n");
break;
case OPCODE_LOAD_MATRIX:
- fprintf(f,"LoadMatrix\n");
- fprintf(f," %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f);
- fprintf(f," %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
- fprintf(f," %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
- fprintf(f," %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
+ _mesa_printf(ctx, "LoadMatrix\n");
+ _mesa_printf(ctx, " %8f %8f %8f %8f\n",
+ n[1].f, n[5].f, n[9].f, n[13].f);
+ _mesa_printf(ctx, " %8f %8f %8f %8f\n",
+ n[2].f, n[6].f, n[10].f, n[14].f);
+ _mesa_printf(ctx, " %8f %8f %8f %8f\n",
+ n[3].f, n[7].f, n[11].f, n[15].f);
+ _mesa_printf(ctx, " %8f %8f %8f %8f\n",
+ n[4].f, n[8].f, n[12].f, n[16].f);
break;
case OPCODE_MULT_MATRIX:
- fprintf(f,"MultMatrix (or Rotate)\n");
- fprintf(f," %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f);
- fprintf(f," %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
- fprintf(f," %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
- fprintf(f," %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
+ _mesa_printf(ctx, "MultMatrix (or Rotate)\n");
+ _mesa_printf(ctx, " %8f %8f %8f %8f\n",
+ n[1].f, n[5].f, n[9].f, n[13].f);
+ _mesa_printf(ctx, " %8f %8f %8f %8f\n",
+ n[2].f, n[6].f, n[10].f, n[14].f);
+ _mesa_printf(ctx, " %8f %8f %8f %8f\n",
+ n[3].f, n[7].f, n[11].f, n[15].f);
+ _mesa_printf(ctx, " %8f %8f %8f %8f\n",
+ n[4].f, n[8].f, n[12].f, n[16].f);
break;
case OPCODE_ORTHO:
- fprintf(f,"Ortho %g %g %g %g %g %g\n",
+ _mesa_printf(ctx, "Ortho %g %g %g %g %g %g\n",
n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
break;
case OPCODE_POP_ATTRIB:
- fprintf(f,"PopAttrib\n");
+ _mesa_printf(ctx, "PopAttrib\n");
break;
case OPCODE_POP_MATRIX:
- fprintf(f,"PopMatrix\n");
+ _mesa_printf(ctx, "PopMatrix\n");
break;
case OPCODE_POP_NAME:
- fprintf(f,"PopName\n");
+ _mesa_printf(ctx, "PopName\n");
break;
case OPCODE_PUSH_ATTRIB:
- fprintf(f,"PushAttrib %x\n", n[1].bf );
+ _mesa_printf(ctx, "PushAttrib %x\n", n[1].bf );
break;
case OPCODE_PUSH_MATRIX:
- fprintf(f,"PushMatrix\n");
+ _mesa_printf(ctx, "PushMatrix\n");
break;
case OPCODE_PUSH_NAME:
- fprintf(f,"PushName %d\n", (int) n[1].ui );
+ _mesa_printf(ctx, "PushName %d\n", (int) n[1].ui );
break;
case OPCODE_RASTER_POS:
- fprintf(f,"RasterPos %g %g %g %g\n", n[1].f, n[2].f,n[3].f,n[4].f);
+ _mesa_printf(ctx, "RasterPos %g %g %g %g\n",
+ n[1].f, n[2].f,n[3].f,n[4].f);
break;
case OPCODE_ROTATE:
- fprintf(f,"Rotate %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f );
+ _mesa_printf(ctx, "Rotate %g %g %g %g\n",
+ n[1].f, n[2].f, n[3].f, n[4].f );
break;
case OPCODE_SCALE:
- fprintf(f,"Scale %g %g %g\n", n[1].f, n[2].f, n[3].f );
+ _mesa_printf(ctx, "Scale %g %g %g\n", n[1].f, n[2].f, n[3].f );
break;
case OPCODE_TRANSLATE:
- fprintf(f,"Translate %g %g %g\n", n[1].f, n[2].f, n[3].f );
+ _mesa_printf(ctx, "Translate %g %g %g\n", n[1].f, n[2].f, n[3].f );
break;
case OPCODE_BIND_TEXTURE:
- fprintf(f,"BindTexture %s %d\n", _mesa_lookup_enum_by_nr(n[1].ui),
- n[2].ui);
+ _mesa_printf(ctx, "BindTexture %s %d\n",
+ _mesa_lookup_enum_by_nr(n[1].ui), n[2].ui);
break;
case OPCODE_SHADE_MODEL:
- fprintf(f,"ShadeModel %s\n", _mesa_lookup_enum_by_nr(n[1].ui));
+ _mesa_printf(ctx, "ShadeModel %s\n",
+ _mesa_lookup_enum_by_nr(n[1].ui));
break;
case OPCODE_MAP1:
- fprintf(f,"Map1 %s %.3f %.3f %d %d\n",
+ _mesa_printf(ctx, "Map1 %s %.3f %.3f %d %d\n",
_mesa_lookup_enum_by_nr(n[1].ui),
n[2].f, n[3].f, n[4].i, n[5].i);
break;
case OPCODE_MAP2:
- fprintf(f,"Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n",
- _mesa_lookup_enum_by_nr(n[1].ui),
- n[2].f, n[3].f, n[4].f, n[5].f,
- n[6].i, n[7].i, n[8].i, n[9].i);
+ _mesa_printf(ctx, "Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n",
+ _mesa_lookup_enum_by_nr(n[1].ui),
+ n[2].f, n[3].f, n[4].f, n[5].f,
+ n[6].i, n[7].i, n[8].i, n[9].i);
break;
case OPCODE_MAPGRID1:
- fprintf(f,"MapGrid1 %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f);
+ _mesa_printf(ctx, "MapGrid1 %d %.3f %.3f\n",
+ n[1].i, n[2].f, n[3].f);
break;
case OPCODE_MAPGRID2:
- fprintf(f,"MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n",
- n[1].i, n[2].f, n[3].f,
- n[4].i, n[5].f, n[6].f);
+ _mesa_printf(ctx, "MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n",
+ n[1].i, n[2].f, n[3].f,
+ n[4].i, n[5].f, n[6].f);
break;
case OPCODE_EVALMESH1:
- fprintf(f,"EvalMesh1 %d %d\n", n[1].i, n[2].i);
+ _mesa_printf(ctx, "EvalMesh1 %d %d\n", n[1].i, n[2].i);
break;
case OPCODE_EVALMESH2:
- fprintf(f,"EvalMesh2 %d %d %d %d\n",
- n[1].i, n[2].i, n[3].i, n[4].i);
+ _mesa_printf(ctx, "EvalMesh2 %d %d %d %d\n",
+ n[1].i, n[2].i, n[3].i, n[4].i);
break;
/*
* meta opcodes/commands
*/
case OPCODE_ERROR:
- fprintf(f,"Error: %s %s\n", enum_string(n[1].e), (const char *)n[2].data );
+ _mesa_printf(ctx, "Error: %s %s\n",
+ enum_string(n[1].e), (const char *)n[2].data );
break;
case OPCODE_CONTINUE:
- fprintf(f,"DISPLAY-LIST-CONTINUE\n");
+ _mesa_printf(ctx, "DISPLAY-LIST-CONTINUE\n");
n = (Node *) n[1].next;
break;
case OPCODE_END_OF_LIST:
- fprintf(f,"END-LIST %u\n", list);
+ _mesa_printf(ctx, "END-LIST %u\n", list);
done = GL_TRUE;
break;
default:
if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
- fprintf(f,"ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
+ _mesa_printf(ctx,
+ "ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
opcode, (void*) n);
return;
}
else {
- fprintf(f,"command %d, %u operands\n",opcode,InstSize[opcode]);
+ _mesa_printf(ctx, "command %d, %u operands\n",
+ opcode, InstSize[opcode]);
}
}
/* increment n to point to next compiled command */
@@ -6351,5 +6364,5 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list )
void mesa_print_display_list( GLuint list )
{
GET_CURRENT_CONTEXT(ctx);
- print_list( ctx, stderr, list );
+ print_list( ctx, list );
}
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index 1c37f5b9a2c..edad15b3e7f 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -1,4 +1,4 @@
-/* $Id: drawpix.c,v 1.60 2002/05/09 21:54:16 brianp Exp $ */
+/* $Id: drawpix.c,v 1.61 2002/06/15 02:38:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -223,3 +223,68 @@ _mesa_Bitmap( GLsizei width, GLsizei height,
ctx->Current.RasterPos[0] += xmove;
ctx->Current.RasterPos[1] += ymove;
}
+
+
+
+#if 0 /* experimental */
+/*
+ * Execute glDrawDepthPixelsMESA(). This function accepts both a color
+ * image and depth (Z) image. Rasterization produces fragments with
+ * color and Z taken from these images. This function is intended for
+ * Z-compositing. Normally, this operation requires two glDrawPixels
+ * calls with stencil testing.
+ */
+void
+_mesa_DrawDepthPixelsMESA( GLsizei width, GLsizei height,
+ GLenum colorFormat, GLenum colorType,
+ const GLvoid *colors,
+ GLenum depthType, const GLvoid *depths )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (width < 0 || height < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE,
+ "glDrawDepthPixelsMESA(width or height < 0" );
+ return;
+ }
+
+ if (ctx->RenderMode==GL_RENDER) {
+ GLint x, y;
+ if (!colors || !depths || !ctx->Current.RasterPosValid) {
+ return;
+ }
+
+ if (ctx->NewState) {
+ _mesa_update_state(ctx);
+ }
+
+ /* Round, to satisfy conformance tests (matches SGI's OpenGL) */
+ x = IROUND(ctx->Current.RasterPos[0]);
+ y = IROUND(ctx->Current.RasterPos[1]);
+
+ ctx->OcclusionResult = GL_TRUE;
+ ctx->Driver.DrawDepthPixelsMESA(ctx, x, y, width, height,
+ colorFormat, colorType, colors,
+ depthType, depths, &ctx->Unpack);
+ }
+ else if (ctx->RenderMode==GL_FEEDBACK) {
+ /* Feedback the current raster pos info */
+ if (ctx->Current.RasterPosValid) {
+ FLUSH_CURRENT( ctx, 0 );
+ FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_DRAW_PIXEL_TOKEN );
+ _mesa_feedback_vertex( ctx,
+ ctx->Current.RasterPos,
+ ctx->Current.RasterColor,
+ ctx->Current.RasterIndex,
+ ctx->Current.RasterTexCoords[0] );
+ }
+ }
+ else if (ctx->RenderMode==GL_SELECT) {
+ if (ctx->Current.RasterPosValid) {
+ _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] );
+ }
+ }
+}
+
+#endif
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 5d29149ca06..bb0c4b705b2 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -1,4 +1,4 @@
-/* $Id: enable.c,v 1.64 2002/06/13 04:28:29 brianp Exp $ */
+/* $Id: enable.c,v 1.65 2002/06/15 02:38:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -173,7 +173,7 @@ _mesa_DisableClientState( GLenum cap )
void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
{
if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug("%s %s (newstate is %x)\n",
+ _mesa_debug(ctx, "%s %s (newstate is %x)\n",
state ? "glEnable" : "glDisable",
_mesa_lookup_enum_by_nr(cap),
ctx->NewState);
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 5770db95333..7f718a7b219 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1,4 +1,4 @@
-/* $Id: get.c,v 1.80 2002/06/13 04:28:29 brianp Exp $ */
+/* $Id: get.c,v 1.81 2002/06/15 02:38:15 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)
- _mesa_debug("glGetBooleanv %s\n", _mesa_lookup_enum_by_nr(pname));
+ _mesa_debug(ctx, "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)
- _mesa_debug("glGetDoublev %s\n", _mesa_lookup_enum_by_nr(pname));
+ _mesa_debug(ctx, "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)
- _mesa_debug("glGetFloatv %s\n", _mesa_lookup_enum_by_nr(pname));
+ _mesa_debug(ctx, "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)
- _mesa_debug("glGetIntegerv %s\n", _mesa_lookup_enum_by_nr(pname));
+ _mesa_debug(ctx, "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)
- _mesa_debug("glGetPointerv %s\n", _mesa_lookup_enum_by_nr(pname));
+ _mesa_debug(ctx, "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)
- _mesa_debug("glGetError <-- %s\n", _mesa_lookup_enum_by_nr(e));
+ _mesa_debug(ctx, "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 8a9cf4b82b1..d6db40353f6 100644
--- a/src/mesa/main/glheader.h
+++ b/src/mesa/main/glheader.h
@@ -1,4 +1,4 @@
-/* $Id: glheader.h,v 1.27 2002/06/13 04:28:29 brianp Exp $ */
+/* $Id: glheader.h,v 1.28 2002/06/15 02:38:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -66,16 +66,13 @@
#endif
#endif
#include <float.h>
+#include <stdarg.h>
#ifdef HAVE_CONFIG_H
#include "conf.h"
#endif
-#ifdef DEBUG
-#include <stdarg.h> /* for _mesa_debug() only */
-#endif
-
#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__)
# define __WIN32__
@@ -259,6 +256,17 @@ typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESC
#endif
+/*
+ * Provide a reasonable replacement for __FUNCTION__ when using
+ * non-GNU C compilers.
+ */
+#if !defined(__GNUC__)
+#define STRINGIZE(x) #x
+#define STRINGIZE_EVAL(x) STRINGIZE(x)
+#define __FUNCTION__ STRINGIZE_EVAL(__FILE__) ", line " STRINGIZE_EVAL(__LINE__)
+#endif
+
+
/* Some compilers don't like some of Mesa's const usage */
#ifdef NO_CONST
# define CONST
diff --git a/src/mesa/main/hint.c b/src/mesa/main/hint.c
index d75823feb9e..44da4ab5008 100644
--- a/src/mesa/main/hint.c
+++ b/src/mesa/main/hint.c
@@ -1,4 +1,4 @@
-/* $Id: hint.c,v 1.11 2002/06/13 04:28:29 brianp Exp $ */
+/* $Id: hint.c,v 1.12 2002/06/15 02:38:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -42,49 +42,43 @@ _mesa_Hint( GLenum target, GLenum mode )
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
- (void) _mesa_try_Hint( ctx, target, mode );
-}
-
-GLboolean
-_mesa_try_Hint( GLcontext *ctx, GLenum target, GLenum mode )
-{
if (MESA_VERBOSE & VERBOSE_API)
_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)");
- return GL_FALSE;
+ return;
}
switch (target) {
case GL_FOG_HINT:
if (ctx->Hint.Fog == mode)
- return GL_TRUE;
+ return;
FLUSH_VERTICES(ctx, _NEW_HINT);
ctx->Hint.Fog = mode;
break;
case GL_LINE_SMOOTH_HINT:
if (ctx->Hint.LineSmooth == mode)
- return GL_TRUE;
+ return;
FLUSH_VERTICES(ctx, _NEW_HINT);
ctx->Hint.LineSmooth = mode;
break;
case GL_PERSPECTIVE_CORRECTION_HINT:
if (ctx->Hint.PerspectiveCorrection == mode)
- return GL_TRUE;
+ return;
FLUSH_VERTICES(ctx, _NEW_HINT);
ctx->Hint.PerspectiveCorrection = mode;
break;
case GL_POINT_SMOOTH_HINT:
if (ctx->Hint.PointSmooth == mode)
- return GL_TRUE;
+ return;
FLUSH_VERTICES(ctx, _NEW_HINT);
ctx->Hint.PointSmooth = mode;
break;
case GL_POLYGON_SMOOTH_HINT:
if (ctx->Hint.PolygonSmooth == mode)
- return GL_TRUE;
+ return;
FLUSH_VERTICES(ctx, _NEW_HINT);
ctx->Hint.PolygonSmooth = mode;
break;
@@ -92,7 +86,7 @@ _mesa_try_Hint( GLcontext *ctx, GLenum target, GLenum mode )
/* GL_EXT_clip_volume_hint */
case GL_CLIP_VOLUME_CLIPPING_HINT_EXT:
if (ctx->Hint.ClipVolumeClipping == mode)
- return GL_TRUE;
+ return;
FLUSH_VERTICES(ctx, _NEW_HINT);
ctx->Hint.ClipVolumeClipping = mode;
break;
@@ -101,10 +95,10 @@ _mesa_try_Hint( GLcontext *ctx, GLenum target, GLenum mode )
case GL_TEXTURE_COMPRESSION_HINT_ARB:
if (!ctx->Extensions.ARB_texture_compression) {
_mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)");
- return GL_FALSE;
+ return;
}
if (ctx->Hint.TextureCompression == mode)
- return GL_TRUE;
+ return;
FLUSH_VERTICES(ctx, _NEW_HINT);
ctx->Hint.TextureCompression = mode;
break;
@@ -113,22 +107,20 @@ _mesa_try_Hint( GLcontext *ctx, GLenum target, GLenum mode )
case GL_GENERATE_MIPMAP_HINT_SGIS:
if (!ctx->Extensions.SGIS_generate_mipmap) {
_mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)");
- return GL_FALSE;
+ return;
}
if (ctx->Hint.GenerateMipmap == mode)
- return GL_TRUE;
+ return;
FLUSH_VERTICES(ctx, _NEW_HINT);
ctx->Hint.GenerateMipmap = mode;
break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)");
- return GL_FALSE;
+ return;
}
if (ctx->Driver.Hint) {
(*ctx->Driver.Hint)( ctx, target, mode );
}
-
- return GL_TRUE;
}
diff --git a/src/mesa/main/hint.h b/src/mesa/main/hint.h
index dbecab2a5b3..6b8f34dc05a 100644
--- a/src/mesa/main/hint.h
+++ b/src/mesa/main/hint.h
@@ -1,10 +1,10 @@
-/* $Id: hint.h,v 1.3 2001/01/24 04:56:20 brianp Exp $ */
+/* $Id: hint.h,v 1.4 2002/06/15 02:38:15 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"),
@@ -32,9 +32,6 @@
#include "mtypes.h"
-extern GLboolean
-_mesa_try_Hint( GLcontext *ctx, GLenum target, GLenum mode );
-
extern void
_mesa_Hint( GLenum target, GLenum mode );
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 7b9339498b1..db762eb2c9e 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -1,4 +1,4 @@
-/* $Id: imports.c,v 1.12 2002/06/13 08:27:32 joukj Exp $ */
+/* $Id: imports.c,v 1.13 2002/06/15 02:38:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -39,12 +39,20 @@
* the renderer should use the XFree86-wrapped system calls.
*/
-#include <stdarg.h>
+/*
+ * XXX when we fully implement the __GLimports mechanism in Mesa, that
+ * should mean that we can remove <stdio.h>, <stdlib.h>, etc, from
+ * glheader.h. Strictly speaking, all system includes should be done
+ * from this file, and not glheader to ensure that core Mesa has no
+ * dependencies on external libraries. Someday...
+ */
+
+
#include "glheader.h"
#include "imports.h"
#include "mem.h"
-#include "mtypes.h"
+
static void *
_mesa_Malloc(__GLcontext *gc, size_t size)
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index b50eba7e9d0..4afc0476af2 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -1,4 +1,4 @@
-/* $Id: light.c,v 1.50 2002/06/13 04:28:29 brianp Exp $ */
+/* $Id: light.c,v 1.51 2002/06/15 02:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -57,7 +57,7 @@ _mesa_ShadeModel( GLenum mode )
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug("glShadeModel %s\n", _mesa_lookup_enum_by_nr(mode));
+ _mesa_debug(ctx, "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)
- _mesa_debug("_mesa_update_material, mask 0x%x\n", bitmask);
+ _mesa_debug(ctx, "_mesa_update_material, mask 0x%x\n", bitmask);
if (!bitmask)
return;
@@ -714,25 +714,16 @@ void _mesa_update_material( GLcontext *ctx,
ctx->Light.Material[1].SpecularIndex = src[1].SpecularIndex;
}
- if (0)
- {
+ if (0) {
struct gl_material *mat = &ctx->Light.Material[0];
- _mesa_debug("update_mat emission : %f %f %f\n",
- mat->Emission[0],
- mat->Emission[1],
- mat->Emission[2]);
- _mesa_debug("update_mat specular : %f %f %f\n",
- mat->Specular[0],
- mat->Specular[1],
- mat->Specular[2]);
- _mesa_debug("update_mat diffuse : %f %f %f\n",
- mat->Diffuse[0],
- mat->Diffuse[1],
- mat->Diffuse[2]);
- _mesa_debug("update_mat ambient : %f %f %f\n",
- mat->Ambient[0],
- mat->Ambient[1],
- mat->Ambient[2]);
+ _mesa_debug(ctx, "update_mat emission : %f %f %f\n",
+ mat->Emission[0], mat->Emission[1], mat->Emission[2]);
+ _mesa_debug(ctx, "update_mat specular : %f %f %f\n",
+ mat->Specular[0], mat->Specular[1], mat->Specular[2]);
+ _mesa_debug(ctx, "update_mat diffuse : %f %f %f\n",
+ mat->Diffuse[0], mat->Diffuse[1], mat->Diffuse[2]);
+ _mesa_debug(ctx, "update_mat ambient : %f %f %f\n",
+ mat->Ambient[0], mat->Ambient[1], mat->Ambient[2]);
}
}
@@ -754,7 +745,7 @@ void _mesa_update_color_material( GLcontext *ctx,
GLuint bitmask = ctx->Light.ColorMaterialBitmask;
if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
- _mesa_debug("_mesa_update_color_material, mask 0x%x\n", bitmask);
+ _mesa_debug(ctx, "_mesa_update_color_material, mask 0x%x\n", bitmask);
/* update emissive colors */
if (bitmask & FRONT_EMISSION_BIT) {
@@ -831,25 +822,16 @@ void _mesa_update_color_material( GLcontext *ctx,
}
}
- if (0)
- {
+ if (0) {
struct gl_material *mat = &ctx->Light.Material[0];
- _mesa_debug("update_color_mat emission : %f %f %f\n",
- mat->Emission[0],
- mat->Emission[1],
- mat->Emission[2]);
- _mesa_debug("update_color_mat specular : %f %f %f\n",
- mat->Specular[0],
- mat->Specular[1],
- mat->Specular[2]);
- _mesa_debug("update_color_mat diffuse : %f %f %f\n",
- mat->Diffuse[0],
- mat->Diffuse[1],
- mat->Diffuse[2]);
- _mesa_debug("update_color_mat ambient : %f %f %f\n",
- mat->Ambient[0],
- mat->Ambient[1],
- mat->Ambient[2]);
+ _mesa_debug(ctx, "update_color_mat emission : %f %f %f\n",
+ mat->Emission[0], mat->Emission[1], mat->Emission[2]);
+ _mesa_debug(ctx, "update_color_mat specular : %f %f %f\n",
+ mat->Specular[0], mat->Specular[1], mat->Specular[2]);
+ _mesa_debug(ctx, "update_color_mat diffuse : %f %f %f\n",
+ mat->Diffuse[0], mat->Diffuse[1], mat->Diffuse[2]);
+ _mesa_debug(ctx, "update_color_mat ambient : %f %f %f\n",
+ mat->Ambient[0], mat->Ambient[1], mat->Ambient[2]);
}
}
@@ -868,9 +850,9 @@ _mesa_ColorMaterial( GLenum face, GLenum mode )
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE&VERBOSE_API)
- _mesa_debug("glColorMaterial %s %s\n",
- _mesa_lookup_enum_by_nr(face),
- _mesa_lookup_enum_by_nr(mode));
+ _mesa_debug(ctx, "glColorMaterial %s %s\n",
+ _mesa_lookup_enum_by_nr(face),
+ _mesa_lookup_enum_by_nr(mode));
bitmask = _mesa_material_bitmask(ctx, face, mode, legal, "glColorMaterial");
diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c
index 8ccd65b94d0..bea0711e7fa 100644
--- a/src/mesa/main/matrix.c
+++ b/src/mesa/main/matrix.c
@@ -1,4 +1,4 @@
-/* $Id: matrix.c,v 1.41 2002/06/13 04:28:29 brianp Exp $ */
+/* $Id: matrix.c,v 1.42 2002/06/15 02:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -157,8 +157,8 @@ _mesa_PushMatrix( void )
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE&VERBOSE_API)
- _mesa_debug("glPushMatrix %s\n",
- _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode));
+ _mesa_debug(ctx, "glPushMatrix %s\n",
+ _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode));
if (stack->Depth + 1 >= stack->MaxDepth) {
_mesa_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix" );
@@ -181,8 +181,8 @@ _mesa_PopMatrix( void )
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
if (MESA_VERBOSE&VERBOSE_API)
- _mesa_debug("glPopMatrix %s\n",
- _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode));
+ _mesa_debug(ctx, "glPopMatrix %s\n",
+ _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode));
if (stack->Depth == 0) {
_mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopMatrix" );
@@ -390,7 +390,7 @@ _mesa_set_viewport( GLcontext *ctx, GLint x, GLint y,
}
if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug("glViewport %d %d %d %d\n", x, y, width, height);
+ _mesa_debug(ctx, "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)
- _mesa_debug("glDepthRange %f %f\n", nearval, farval);
+ _mesa_debug(ctx, "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 5c7d642ba84..846ed85de49 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1,4 +1,4 @@
-/* $Id: mtypes.h,v 1.78 2002/06/13 04:28:29 brianp Exp $ */
+/* $Id: mtypes.h,v 1.79 2002/06/15 02:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1857,15 +1857,6 @@ enum _debug {
#define Elements(x) sizeof(x)/sizeof(*(x))
-/*
- * Provide a reasonable replacement for __FUNCTION__ when using
- * non-GNU C compilers.
- */
-#if !defined(__GNUC__)
-#define STRINGIZE(x) #x
-#define STRINGIZE_EVAL(x) STRINGIZE(x)
-#define __FUNCTION__ STRINGIZE_EVAL(__FILE__) ", line " STRINGIZE_EVAL(__LINE__)
-#endif
/* Eventually let the driver specify what statechanges require a flush:
*/
diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c
index ee9eb3a7214..95371579fad 100644
--- a/src/mesa/main/polygon.c
+++ b/src/mesa/main/polygon.c
@@ -1,4 +1,4 @@
-/* $Id: polygon.c,v 1.22 2002/06/13 04:49:17 brianp Exp $ */
+/* $Id: polygon.c,v 1.23 2002/06/15 02:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -47,7 +47,7 @@ _mesa_CullFace( GLenum mode )
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE&VERBOSE_API)
- _mesa_debug("glCullFace %s\n", _mesa_lookup_enum_by_nr(mode));
+ _mesa_debug(ctx, "glCullFace %s\n", _mesa_lookup_enum_by_nr(mode));
if (mode!=GL_FRONT && mode!=GL_BACK && mode!=GL_FRONT_AND_BACK) {
_mesa_error( ctx, GL_INVALID_ENUM, "glCullFace" );
@@ -73,7 +73,7 @@ _mesa_FrontFace( GLenum mode )
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE&VERBOSE_API)
- _mesa_debug("glFrontFace %s\n", _mesa_lookup_enum_by_nr(mode));
+ _mesa_debug(ctx, "glFrontFace %s\n", _mesa_lookup_enum_by_nr(mode));
if (mode!=GL_CW && mode!=GL_CCW) {
_mesa_error( ctx, GL_INVALID_ENUM, "glFrontFace" );
@@ -101,7 +101,7 @@ _mesa_PolygonMode( GLenum face, GLenum mode )
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE&VERBOSE_API)
- _mesa_debug("glPolygonMode %s %s\n",
+ _mesa_debug(ctx, "glPolygonMode %s %s\n",
_mesa_lookup_enum_by_nr(face),
_mesa_lookup_enum_by_nr(mode));
@@ -154,7 +154,7 @@ _mesa_PolygonStipple( const GLubyte *pattern )
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE&VERBOSE_API)
- _mesa_debug("glPolygonStipple\n");
+ _mesa_debug(ctx, "glPolygonStipple\n");
FLUSH_VERTICES(ctx, _NEW_POLYGONSTIPPLE);
_mesa_unpack_polygon_stipple(pattern, ctx->PolygonStipple, &ctx->Unpack);
@@ -172,7 +172,7 @@ _mesa_GetPolygonStipple( GLubyte *dest )
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE&VERBOSE_API)
- _mesa_debug("glGetPolygonStipple\n");
+ _mesa_debug(ctx, "glGetPolygonStipple\n");
_mesa_pack_polygon_stipple(ctx->PolygonStipple, dest, &ctx->Pack);
}
@@ -186,7 +186,7 @@ _mesa_PolygonOffset( GLfloat factor, GLfloat units )
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE&VERBOSE_API)
- _mesa_debug("glPolygonOffset %f %f\n", factor, units);
+ _mesa_debug(ctx, "glPolygonOffset %f %f\n", factor, units);
if (ctx->Polygon.OffsetFactor == factor &&
ctx->Polygon.OffsetUnits == units)
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index b75a787862f..ce145d800bc 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -1,4 +1,4 @@
-/* $Id: texformat.c,v 1.11 2001/06/15 14:18:46 brianp Exp $ */
+/* $Id: texformat.c,v 1.12 2002/06/15 02:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -438,6 +438,153 @@ const struct gl_texture_format _mesa_texformat_ci8 = {
};
+/* Big-endian */
+#if 0
+const struct gl_texture_format _mesa_texformat_abgr8888 = {
+ MESA_FORMAT_ABGR8888, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_INT_8_8_8_8, /* Type */
+ 8, /* RedBits */
+ 8, /* GreenBits */
+ 8, /* BlueBits */
+ 8, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 4, /* TexelBytes */
+ fetch_1d_texel_abgr8888, /* FetchTexel1D */
+ fetch_2d_texel_abgr8888, /* FetchTexel2D */
+ fetch_3d_texel_abgr8888, /* FetchTexel3D */
+};
+
+const struct gl_texture_format _mesa_texformat_bgra8888 = {
+ MESA_FORMAT_BGRA8888, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_INT_8_8_8_8, /* Type */
+ 8, /* RedBits */
+ 8, /* GreenBits */
+ 8, /* BlueBits */
+ 8, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 4, /* TexelBytes */
+ fetch_1d_texel_bgra8888, /* FetchTexel1D */
+ fetch_2d_texel_bgra8888, /* FetchTexel2D */
+ fetch_3d_texel_bgra8888, /* FetchTexel3D */
+};
+
+const struct gl_texture_format _mesa_texformat_bgr888 = {
+ MESA_FORMAT_BGR888, /* MesaFormat */
+ GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_BYTE, /* Type */
+ 8, /* RedBits */
+ 8, /* GreenBits */
+ 8, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 3, /* TexelBytes */
+ fetch_1d_texel_bgr888, /* FetchTexel1D */
+ fetch_2d_texel_bgr888, /* FetchTexel2D */
+ fetch_3d_texel_bgr888, /* FetchTexel3D */
+};
+
+const struct gl_texture_format _mesa_texformat_bgr565 = {
+ MESA_FORMAT_BGR565, /* MesaFormat */
+ GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_SHORT_5_6_5, /* Type */
+ 5, /* RedBits */
+ 6, /* GreenBits */
+ 5, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2, /* TexelBytes */
+ fetch_1d_texel_bgr565, /* FetchTexel1D */
+ fetch_2d_texel_bgr565, /* FetchTexel2D */
+ fetch_3d_texel_bgr565, /* FetchTexel3D */
+};
+
+const struct gl_texture_format _mesa_texformat_bgra4444 = {
+ MESA_FORMAT_BGRA4444, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_SHORT_4_4_4_4_REV, /* Type */
+ 4, /* RedBits */
+ 4, /* GreenBits */
+ 4, /* BlueBits */
+ 4, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2, /* TexelBytes */
+ fetch_1d_texel_bgra4444, /* FetchTexel1D */
+ fetch_2d_texel_bgra4444, /* FetchTexel2D */
+ fetch_3d_texel_bgra4444, /* FetchTexel3D */
+};
+
+const struct gl_texture_format _mesa_texformat_bgra5551 = {
+ MESA_FORMAT_BGRA5551, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_SHORT_1_5_5_5_REV, /* Type */
+ 5, /* RedBits */
+ 5, /* GreenBits */
+ 5, /* BlueBits */
+ 1, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2, /* TexelBytes */
+ fetch_1d_texel_bgra1555, /* FetchTexel1D */
+ fetch_2d_texel_bgra1555, /* FetchTexel2D */
+ fetch_3d_texel_bgra1555, /* FetchTexel3D */
+};
+
+const struct gl_texture_format _mesa_texformat_la88 = {
+ MESA_FORMAT_LA88, /* MesaFormat */
+ GL_LUMINANCE_ALPHA, /* BaseFormat */
+ GL_UNSIGNED_BYTE, /* Type */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 8, /* AlphaBits */
+ 8, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2, /* TexelBytes */
+ fetch_1d_texel_la88, /* FetchTexel1D */
+ fetch_2d_texel_la88, /* FetchTexel2D */
+ fetch_3d_texel_la88, /* FetchTexel3D */
+};
+
+const struct gl_texture_format _mesa_texformat_bgr233 = {
+ MESA_FORMAT_BGR233, /* MesaFormat */
+ GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_BYTE_3_3_2, /* Type */
+ 3, /* RedBits */
+ 3, /* GreenBits */
+ 2, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 1, /* TexelBytes */
+ fetch_1d_texel_bgr233, /* FetchTexel1D */
+ fetch_2d_texel_bgr233, /* FetchTexel2D */
+ fetch_3d_texel_bgr233, /* FetchTexel3D */
+};
+#endif
+
/* =============================================================
* Null format:
*/
@@ -472,8 +619,8 @@ _mesa_is_hardware_tex_format( const struct gl_texture_format *format )
/* Given an internal texture format (or 1, 2, 3, 4) return a pointer
* to a gl_texture_format which which to store the texture.
* This is called via ctx->Driver.ChooseTextureFormat().
- * Hardware drivers should not use this function, but instead a
- * specialized function.
+ * Hardware drivers typically override this function with a specialized
+ * version.
*/
const struct gl_texture_format *
_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
diff --git a/src/mesa/main/texformat.h b/src/mesa/main/texformat.h
index a8c5b525521..9d0497708c4 100644
--- a/src/mesa/main/texformat.h
+++ b/src/mesa/main/texformat.h
@@ -1,4 +1,4 @@
-/* $Id: texformat.h,v 1.8 2002/06/12 00:52:50 brianp Exp $ */
+/* $Id: texformat.h,v 1.9 2002/06/15 02:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -33,12 +33,15 @@
#include "mtypes.h"
-/* The Mesa internal texture image types. These will be set to their
- * default value, but may be changed by drivers as required.
+/*
+ * The Mesa internal texture image types.
+ * All texture images must be stored in one of these formats.
*/
enum _format {
/* Hardware-friendly formats. Drivers can override the default
* formats and convert texture images to one of these as required.
+ * The driver's ChooseTextureFormat() function will choose one of
+ * these formats.
* These formats are all little endian, as shown below. They will be
* most useful for x86-based PC graphics card drivers.
*
@@ -85,7 +88,7 @@ enum _format {
*
* NOTE: Because these are based on the GLchan datatype, one cannot
* assume 8 bits per channel with these formats. If you require
- * GLubyte per channel, use one of the hardware formats above.
+ * GLubyte channels, use one of the hardware formats above.
*/
MESA_FORMAT_RGBA,
MESA_FORMAT_RGB,
diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h
index 7a91e6393c6..8345cfc185c 100644
--- a/src/mesa/main/texformat_tmp.h
+++ b/src/mesa/main/texformat_tmp.h
@@ -1,4 +1,4 @@
-/* $Id: texformat_tmp.h,v 1.4 2002/05/09 20:51:05 keithw Exp $ */
+/* $Id: texformat_tmp.h,v 1.5 2002/06/15 02:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -284,6 +284,98 @@ static void FETCH(ci8)( const struct gl_texture_image *texImage,
}
+/* big-endian */
+
+static void FETCH(abgr8888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLvoid *texel )
+{
+ const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 );
+ GLchan *rgba = (GLchan *) texel;
+ rgba[RCOMP] = UBYTE_TO_CHAN( src[3] );
+ rgba[GCOMP] = UBYTE_TO_CHAN( src[2] );
+ rgba[BCOMP] = UBYTE_TO_CHAN( src[1] );
+ rgba[ACOMP] = UBYTE_TO_CHAN( src[0] );
+}
+
+static void FETCH(bgra8888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLvoid *texel )
+{
+ const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 );
+ GLchan *rgba = (GLchan *) texel;
+ rgba[RCOMP] = UBYTE_TO_CHAN( src[2] );
+ rgba[GCOMP] = UBYTE_TO_CHAN( src[1] );
+ rgba[BCOMP] = UBYTE_TO_CHAN( src[0] );
+ rgba[ACOMP] = UBYTE_TO_CHAN( src[3] );
+}
+
+static void FETCH(bgr888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLvoid *texel )
+{
+ const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 );
+ GLchan *rgba = (GLchan *) texel;
+ rgba[RCOMP] = UBYTE_TO_CHAN( src[2] );
+ rgba[GCOMP] = UBYTE_TO_CHAN( src[1] );
+ rgba[BCOMP] = UBYTE_TO_CHAN( src[0] );
+ rgba[ACOMP] = CHAN_MAX;
+}
+
+static void FETCH(bgr565)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLvoid *texel )
+{
+ const GLushort *src = USHORT_SRC( texImage, i, j, k );
+ GLchan *rgba = (GLchan *) texel; GLushort s = *src;
+ rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 );
+ rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc );
+ rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 );
+ rgba[ACOMP] = CHAN_MAX;
+}
+
+static void FETCH(bgra4444)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLvoid *texel )
+{
+ const GLushort *src = USHORT_SRC( texImage, i, j, k );
+ GLchan *rgba = (GLchan *) texel; GLushort s = *src;
+ rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf );
+ rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf );
+ rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf );
+ rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf );
+}
+
+static void FETCH(bgra5551)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLvoid *texel )
+{
+ const GLushort *src = USHORT_SRC( texImage, i, j, k );
+ GLchan *rgba = (GLchan *) texel; GLushort s = *src;
+ rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f );
+ rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f );
+ rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0x1f) * 255 / 0x1f );
+ rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 );
+}
+
+static void FETCH(la88)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLvoid *texel )
+{
+ const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 );
+ GLchan *rgba = (GLchan *) texel;
+ rgba[RCOMP] = UBYTE_TO_CHAN( src[0] );
+ rgba[GCOMP] = UBYTE_TO_CHAN( src[0] );
+ rgba[BCOMP] = UBYTE_TO_CHAN( src[0] );
+ rgba[ACOMP] = UBYTE_TO_CHAN( src[1] );
+}
+
+static void FETCH(bgr233)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLvoid *texel )
+{
+ const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
+ GLchan *rgba = (GLchan *) texel; GLubyte s = *src;
+ rgba[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 );
+ rgba[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 );
+ rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 );
+ rgba[ACOMP] = CHAN_MAX;
+}
+
+
+
#undef CHAN_SRC
#undef UBYTE_SRC
#undef USHORT_SRC
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index a2d40956dfd..97140723e7c 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1,4 +1,4 @@
-/* $Id: texobj.c,v 1.53 2002/06/13 04:49:17 brianp Exp $ */
+/* $Id: texobj.c,v 1.54 2002/06/15 02:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -565,7 +565,7 @@ _mesa_BindTexture( GLenum target, GLuint texName )
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
- _mesa_debug("glBindTexture %s %d\n",
+ _mesa_debug(ctx, "glBindTexture %s %d\n",
_mesa_lookup_enum_by_nr(target), (GLint) texName);
switch (target) {
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 464bd3adfd2..8319613804f 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -1,4 +1,4 @@
-/* $Id: texstate.c,v 1.73 2002/06/13 04:49:17 brianp Exp $ */
+/* $Id: texstate.c,v 1.74 2002/06/15 02:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -454,7 +454,7 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
}
if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE))
- _mesa_debug("glTexEnv %s %s %.1f(%s) ...\n",
+ _mesa_debug(ctx, "glTexEnv %s %s %.1f(%s) ...\n",
_mesa_lookup_enum_by_nr(target),
_mesa_lookup_enum_by_nr(pname),
*param,
@@ -950,7 +950,7 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE))
- _mesa_debug("texPARAM %s %s %d...\n",
+ _mesa_debug(ctx, "texPARAM %s %s %d...\n",
_mesa_lookup_enum_by_nr(target),
_mesa_lookup_enum_by_nr(pname),
eparam);
@@ -1764,7 +1764,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE))
- _mesa_debug("texGEN %s %s %x...\n",
+ _mesa_debug(ctx, "texGEN %s %s %x...\n",
_mesa_lookup_enum_by_nr(coord),
_mesa_lookup_enum_by_nr(pname),
*(int *)params);
@@ -2303,7 +2303,7 @@ _mesa_ActiveTextureARB( GLenum target )
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
- _mesa_debug("glActiveTexture %s\n",
+ _mesa_debug(ctx, "glActiveTexture %s\n",
_mesa_lookup_enum_by_nr(target));
if (texUnit > ctx->Const.MaxTextureUnits) {
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 4e03f21c873..e9138693664 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1,4 +1,4 @@
-/* $Id: varray.c,v 1.44 2002/06/13 04:49:17 brianp Exp $ */
+/* $Id: varray.c,v 1.45 2002/06/15 02:38:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -60,9 +60,8 @@ _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
}
if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
- _mesa_debug("glVertexPointer( sz %d type %s stride %d )\n", size,
- _mesa_lookup_enum_by_nr( type ),
- stride);
+ _mesa_debug(ctx, "glVertexPointer( sz %d type %s stride %d )\n", size,
+ _mesa_lookup_enum_by_nr( type ), stride);
/* always need to check that <type> is legal */
switch (type) {
@@ -112,9 +111,8 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
}
if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
- _mesa_debug("glNormalPointer( type %s stride %d )\n",
- _mesa_lookup_enum_by_nr( type ),
- stride);
+ _mesa_debug(ctx, "glNormalPointer( type %s stride %d )\n",
+ _mesa_lookup_enum_by_nr( type ), stride);
switch (type) {
case GL_BYTE:
@@ -168,9 +166,8 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
}
if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
- _mesa_debug("glColorPointer( sz %d type %s stride %d )\n", size,
- _mesa_lookup_enum_by_nr( type ),
- stride);
+ _mesa_debug(ctx, "glColorPointer( sz %d type %s stride %d )\n", size,
+ _mesa_lookup_enum_by_nr( type ), stride);
switch (type) {
case GL_BYTE:
@@ -320,7 +317,7 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
}
if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
- _mesa_debug("glSecondaryColorPointer( sz %d type %s stride %d )\n",
+ _mesa_debug(ctx, "glSecondaryColorPointer( sz %d type %s stride %d )\n",
size, _mesa_lookup_enum_by_nr( type ), stride);
switch (type) {
@@ -387,11 +384,8 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
}
if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
- _mesa_debug("glTexCoordPointer( unit %u sz %d type %s stride %d )\n",
- texUnit,
- size,
- _mesa_lookup_enum_by_nr( type ),
- stride);
+ _mesa_debug(ctx, "glTexCoordPointer(unit %u sz %d type %s stride %d)\n",
+ texUnit, size, _mesa_lookup_enum_by_nr( type ), stride);
/* always need to check that <type> is legal */
switch (type) {
@@ -768,7 +762,7 @@ _mesa_LockArraysEXT(GLint first, GLsizei count)
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug("glLockArrays %d %d\n", first, count);
+ _mesa_debug(ctx, "glLockArrays %d %d\n", first, count);
if (first == 0 && count > 0 &&
count <= (GLint) ctx->Const.MaxArrayLockSize) {
@@ -795,7 +789,7 @@ _mesa_UnlockArraysEXT( void )
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug("glUnlockArrays\n");
+ _mesa_debug(ctx, "glUnlockArrays\n");
ctx->Array.LockFirst = 0;
ctx->Array.LockCount = 0;