summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2002-06-29 19:48:15 +0000
committerBrian Paul <[email protected]>2002-06-29 19:48:15 +0000
commit4e9676fb13f60ecdbc247b120031f18cd3febcb0 (patch)
tree9f310d4b547592b025b5a7063aaf2b629bef6676 /src/mesa/main
parentf1ad551604122dd2679dbd31ae6b2fa1197e9848 (diff)
Applied Matt Sealey's patch to remove/isolate all stdio.h function calls.
Instead of mstdio.[ch], use imports.[ch] to isolate these functions.
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/colortab.c6
-rw-r--r--src/mesa/main/context.c164
-rw-r--r--src/mesa/main/context.h18
-rw-r--r--src/mesa/main/debug.c7
-rw-r--r--src/mesa/main/dispatch.c4
-rw-r--r--src/mesa/main/dlist.c4
-rw-r--r--src/mesa/main/enable.c32
-rw-r--r--src/mesa/main/enums.c5
-rw-r--r--src/mesa/main/get.c46
-rw-r--r--src/mesa/main/hash.c17
-rw-r--r--src/mesa/main/imports.c213
-rw-r--r--src/mesa/main/imports.h24
-rw-r--r--src/mesa/main/mtypes.h6
-rw-r--r--src/mesa/main/texformat.c4
-rw-r--r--src/mesa/main/teximage.c168
-rw-r--r--src/mesa/main/texobj.c4
-rw-r--r--src/mesa/main/texstate.c24
-rw-r--r--src/mesa/main/texstore.c4
-rw-r--r--src/mesa/main/texutil_tmp.h38
-rw-r--r--src/mesa/main/vtxfmt.c4
20 files changed, 384 insertions, 408 deletions
diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c
index d4c745fab2f..417954369ae 100644
--- a/src/mesa/main/colortab.c
+++ b/src/mesa/main/colortab.c
@@ -1,4 +1,4 @@
-/* $Id: colortab.c,v 1.43 2002/06/08 12:39:18 brianp Exp $ */
+/* $Id: colortab.c,v 1.44 2002/06/29 19:48:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -322,9 +322,7 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
table->Format = (GLenum) 0;
}
else {
- char msg[100];
- sprintf(msg, "glColorTable(width=%d)", width);
- _mesa_error(ctx, GL_INVALID_VALUE, msg);
+ _mesa_error(ctx, GL_INVALID_VALUE, "glColorTable(width=%d)", width);
}
return;
}
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index bead62cdf3d..9a141d9db20 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.173 2002/06/23 02:53:22 brianp Exp $ */
+/* $Id: context.c,v 1.174 2002/06/29 19:48:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -579,13 +579,14 @@ one_time_init( GLcontext *ctx )
#endif
if (ctx->imports.getenv(ctx, "MESA_DEBUG")) {
_glapi_noop_enable_warnings(GL_TRUE);
+ _glapi_set_warning_func( (_glapi_warning_func) _mesa_warning );
}
else {
_glapi_noop_enable_warnings(GL_FALSE);
}
#if defined(DEBUG) && defined(__DATE__) && defined(__TIME__)
- fprintf(stderr, "Mesa DEBUG build %s %s\n", __DATE__, __TIME__);
+ _mesa_debug(ctx, "Mesa DEBUG build %s %s\n", __DATE__, __TIME__);
#endif
alreadyCalled = GL_TRUE;
@@ -1480,7 +1481,7 @@ init_attrib_groups( GLcontext *ctx )
ctx->NoDither = ctx->imports.getenv(ctx, "MESA_NO_DITHER") ? GL_TRUE : GL_FALSE;
if (ctx->NoDither) {
if (ctx->imports.getenv(ctx, "MESA_DEBUG")) {
- fprintf(stderr, "MESA_NO_DITHER set - dithering disabled\n");
+ _mesa_debug(ctx, "MESA_NO_DITHER set - dithering disabled\n");
}
ctx->Color.DitherFlag = GL_FALSE;
}
@@ -2089,28 +2090,28 @@ _mesa_copy_context( const GLcontext *src, GLcontext *dst, GLuint mask )
static void print_info( void )
{
- fprintf(stderr, "Mesa GL_VERSION = %s\n",
+ _mesa_debug(NULL, "Mesa GL_VERSION = %s\n",
(char *) _mesa_GetString(GL_VERSION));
- fprintf(stderr, "Mesa GL_RENDERER = %s\n",
+ _mesa_debug(NULL, "Mesa GL_RENDERER = %s\n",
(char *) _mesa_GetString(GL_RENDERER));
- fprintf(stderr, "Mesa GL_VENDOR = %s\n",
+ _mesa_debug(NULL, "Mesa GL_VENDOR = %s\n",
(char *) _mesa_GetString(GL_VENDOR));
- fprintf(stderr, "Mesa GL_EXTENSIONS = %s\n",
+ _mesa_debug(NULL, "Mesa GL_EXTENSIONS = %s\n",
(char *) _mesa_GetString(GL_EXTENSIONS));
#if defined(THREADS)
- fprintf(stderr, "Mesa thread-safe: YES\n");
+ _mesa_debug(NULL, "Mesa thread-safe: YES\n");
#else
- fprintf(stderr, "Mesa thread-safe: NO\n");
+ _mesa_debug(NULL, "Mesa thread-safe: NO\n");
#endif
#if defined(USE_X86_ASM)
- fprintf(stderr, "Mesa x86-optimized: YES\n");
+ _mesa_debug(NULL, "Mesa x86-optimized: YES\n");
#else
- fprintf(stderr, "Mesa x86-optimized: NO\n");
+ _mesa_debug(NULL, "Mesa x86-optimized: NO\n");
#endif
#if defined(USE_SPARC_ASM)
- fprintf(stderr, "Mesa sparc-optimized: YES\n");
+ _mesa_debug(NULL, "Mesa sparc-optimized: YES\n");
#else
- fprintf(stderr, "Mesa sparc-optimized: NO\n");
+ _mesa_debug(NULL, "Mesa sparc-optimized: NO\n");
#endif
}
@@ -2270,112 +2271,12 @@ _mesa_get_dispatch(GLcontext *ctx)
/*
- * This function is called when the Mesa user has stumbled into a code
- * path which may not be implemented fully or correctly.
- */
-void _mesa_problem( const GLcontext *ctx, const char *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");
-#else
- fprintf( stderr, "Please report to the Mesa bug database at www.mesa3d.org\n" );
-#endif
- }
-}
-
-
-
-/*
- * This is called to inform the user that he or she has tried to do
- * something illogical or if there's likely a bug in their program
- * (like enabled depth testing without a depth buffer).
- */
-void
-_mesa_warning( const GLcontext *ctx, const char *s )
-{
- (*ctx->imports.warning)((__GLcontext *) ctx, (char *) s);
-}
-
-
-
-/*
- * This is Mesa's error handler. Normally, all that's done is the updating
- * of the current error value. If Mesa is compiled with -DDEBUG or if the
- * environment variable "MESA_DEBUG" is defined then a real error message
- * is printed to stderr.
- * Input: ctx - the GL context
- * error - the error value
- * where - usually the name of function where error was detected
+ * Record the given error code and call the driver's Error function if defined.
+ * This is called via _mesa_error().
*/
void
-_mesa_error( GLcontext *ctx, GLenum error, const char *where )
+_mesa_record_error( GLcontext *ctx, GLenum error )
{
- 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;
- else
- debug = GL_TRUE;
-#else
- if (debugEnv)
- debug = GL_TRUE;
- else
- debug = GL_FALSE;
-#endif
-
- if (debug) {
- const char *errstr;
- switch (error) {
- case GL_NO_ERROR:
- errstr = "GL_NO_ERROR";
- break;
- case GL_INVALID_VALUE:
- errstr = "GL_INVALID_VALUE";
- break;
- case GL_INVALID_ENUM:
- errstr = "GL_INVALID_ENUM";
- break;
- case GL_INVALID_OPERATION:
- errstr = "GL_INVALID_OPERATION";
- break;
- case GL_STACK_OVERFLOW:
- errstr = "GL_STACK_OVERFLOW";
- break;
- case GL_STACK_UNDERFLOW:
- errstr = "GL_STACK_UNDERFLOW";
- break;
- case GL_OUT_OF_MEMORY:
- errstr = "GL_OUT_OF_MEMORY";
- break;
- case GL_TABLE_TOO_LARGE:
- errstr = "GL_TABLE_TOO_LARGE";
- break;
- default:
- errstr = "unknown";
- break;
- }
- fprintf(stderr, "Mesa user error: %s in %s\n", errstr, where);
- }
-
if (!ctx)
return;
@@ -2390,37 +2291,6 @@ _mesa_error( GLcontext *ctx, GLenum error, const char *where )
}
-/*
- * Call this to report debug information. Uses stderr.
- */
-void
-_mesa_debug( const GLcontext *ctx, const char *fmtString, ... )
-{
- char s[1000];
- va_list args;
- va_start( args, fmtString );
- vsprintf(s, fmtString, args);
- (void) ctx->imports.fprintf( (__GLcontext *) ctx, stderr, s );
- va_end( args );
-}
-
-
-/*
- * A wrapper for printf. Uses stdout.
- */
-void
-_mesa_printf( const GLcontext *ctx, const char *fmtString, ... )
-{
- char s[1000];
- va_list args;
- va_start( args, fmtString );
- vsprintf(s, fmtString, args);
- (void) ctx->imports.fprintf( (__GLcontext *) ctx, stdout, s );
- va_end( args );
-}
-
-
-
void
_mesa_Finish( void )
{
diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index 8e9524fec58..2b359d0968e 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -1,4 +1,4 @@
-/* $Id: context.h,v 1.32 2002/06/15 02:38:15 brianp Exp $ */
+/* $Id: context.h,v 1.33 2002/06/29 19:48:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -31,6 +31,7 @@
#include "glapi.h"
#include "mtypes.h"
+#include "imports.h"
/*
@@ -229,20 +230,7 @@ _mesa_get_dispatch(GLcontext *ctx);
*/
extern void
-_mesa_problem( const GLcontext *ctx, const char *s );
-
-extern void
-_mesa_warning( const GLcontext *ctx, const char *s );
-
-extern void
-_mesa_error( GLcontext *ctx, GLenum error, const char *s );
-
-extern void
-_mesa_debug( const GLcontext *ctx, const char *fmtString, ... );
-
-extern void
-_mesa_printf( const GLcontext *ctx, const char *fmtString, ... );
-
+_mesa_record_error( GLcontext *ctx, GLenum error );
extern void
diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c
index 7a3a88edf2a..039f7a01a7b 100644
--- a/src/mesa/main/debug.c
+++ b/src/mesa/main/debug.c
@@ -1,4 +1,4 @@
-/* $Id: debug.c,v 1.12 2001/03/29 21:16:25 keithw Exp $ */
+/* $Id: debug.c,v 1.13 2002/06/29 19:48:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -25,11 +25,12 @@
*/
#include "mtypes.h"
+#include "context.h"
#include "debug.h"
void _mesa_print_state( const char *msg, GLuint state )
{
- fprintf(stderr,
+ _mesa_debug(NULL,
"%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
msg,
state,
@@ -63,7 +64,7 @@ void _mesa_print_state( const char *msg, GLuint state )
void _mesa_print_tri_caps( const char *name, GLuint flags )
{
- fprintf(stderr,
+ _mesa_debug(NULL,
"%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
name,
flags,
diff --git a/src/mesa/main/dispatch.c b/src/mesa/main/dispatch.c
index 0ed24afd30a..463bdb70d04 100644
--- a/src/mesa/main/dispatch.c
+++ b/src/mesa/main/dispatch.c
@@ -1,4 +1,4 @@
-/* $Id: dispatch.c,v 1.26 2001/12/15 16:42:59 brianp Exp $ */
+/* $Id: dispatch.c,v 1.27 2002/06/29 19:48:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -62,7 +62,7 @@
#endif
-#if 0 /* Use this to log GL calls to stdout */
+#if 0 /* Use this to log GL calls to stdout (for DEBUG only!) */
#define F stdout
#define DISPATCH(FUNC, ARGS, MESSAGE) \
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 3523db550a2..1409f0ee420 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -1,4 +1,4 @@
-/* $Id: dlist.c,v 1.90 2002/06/15 02:38:15 brianp Exp $ */
+/* $Id: dlist.c,v 1.91 2002/06/29 19:48:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -4817,7 +4817,7 @@ execute_list( GLcontext *ctx, GLuint list )
default:
{
char msg[1000];
- sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
+ _mesa_sprintf( ctx, msg, "Error in execute_list: opcode=%d", (int) opcode);
_mesa_problem( ctx, msg );
}
done = GL_TRUE;
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index aef516690ae..140358b463a 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -1,4 +1,4 @@
-/* $Id: enable.c,v 1.67 2002/06/18 16:53:46 brianp Exp $ */
+/* $Id: enable.c,v 1.68 2002/06/29 19:48:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -44,9 +44,8 @@
#define CHECK_EXTENSION(EXTNAME, CAP) \
if (!ctx->Extensions.EXTNAME) { \
- char s[100]; \
- sprintf(s, "gl%sClientState(0x%x)", state ? "Enable" : "Disable", CAP);\
- _mesa_error(ctx, GL_INVALID_ENUM, s); \
+ _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)", \
+ state ? "Enable" : "Disable", CAP); \
return; \
}
@@ -117,11 +116,8 @@ client_state( GLcontext *ctx, GLenum cap, GLboolean state )
}
break;
default:
- {
- char s[100];
- sprintf(s, "glEnable/DisableClientState(0x%x)", cap);
- _mesa_error( ctx, GL_INVALID_ENUM, s);
- }
+ _mesa_error( ctx, GL_INVALID_ENUM,
+ "glEnable/DisableClientState(0x%x)", cap);
return;
}
@@ -166,9 +162,8 @@ _mesa_DisableClientState( GLenum cap )
#undef CHECK_EXTENSION
#define CHECK_EXTENSION(EXTNAME, CAP) \
if (!ctx->Extensions.EXTNAME) { \
- char s[100]; \
- sprintf(s, "gl%s(0x%x)", state ? "Enable" : "Disable", CAP); \
- _mesa_error(ctx, GL_INVALID_ENUM, s); \
+ _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
+ state ? "Enable" : "Disable", CAP); \
return; \
}
@@ -895,11 +890,8 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
break;
default:
- {
- char s[100];
- sprintf(s, "%s(0x%x)", state ? "glEnable" : "glDisable", cap);
- _mesa_error(ctx, GL_INVALID_ENUM, s);
- }
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "%s(0x%x)", state ? "glEnable" : "glDisable", cap);
return;
}
@@ -1272,11 +1264,7 @@ _mesa_IsEnabled( GLenum cap )
}
default:
- {
- char s[100];
- sprintf(s, "glIsEnabled(0x%x)", (int) cap);
- _mesa_error( ctx, GL_INVALID_ENUM, s );
- }
+ _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap);
return GL_FALSE;
}
}
diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c
index 9d5a567742a..93abf2ab5f8 100644
--- a/src/mesa/main/enums.c
+++ b/src/mesa/main/enums.c
@@ -1,4 +1,4 @@
-/* $Id: enums.c,v 1.20 2001/06/08 20:10:55 brianp Exp $ */
+/* $Id: enums.c,v 1.21 2002/06/29 19:48:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -33,6 +33,7 @@
#else
#include "glheader.h"
#include "enums.h"
+#include "imports.h"
#include "mem.h"
#endif
@@ -928,7 +929,7 @@ const char *_mesa_lookup_enum_by_nr( int nr )
}
else {
/* this isn't re-entrant safe, no big deal here */
- sprintf(token_tmp, "0x%x", nr);
+ _mesa_sprintf(NULL, token_tmp, "0x%x", nr);
return token_tmp;
}
}
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 73e924e6b39..a99a5fb6c90 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1,4 +1,4 @@
-/* $Id: get.c,v 1.83 2002/06/18 16:53:46 brianp Exp $ */
+/* $Id: get.c,v 1.84 2002/06/29 19:48:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -63,33 +63,29 @@
#define CHECK_EXTENSION_B(EXTNAME, PNAME) \
if (!ctx->Extensions.EXTNAME) { \
- char s[100]; \
- sprintf(s, "glGetBooleanv(0x%x)", (int) PNAME); \
- _mesa_error(ctx, GL_INVALID_VALUE, s); \
+ _mesa_error(ctx, GL_INVALID_VALUE, \
+ "glGetBooleanv(0x%x)", (int) PNAME); \
return; \
}
#define CHECK_EXTENSION_I(EXTNAME, PNAME) \
if (!ctx->Extensions.EXTNAME) { \
- char s[100]; \
- sprintf(s, "glGetIntegerv(0x%x)", (int) PNAME); \
- _mesa_error(ctx, GL_INVALID_VALUE, s); \
+ _mesa_error(ctx, GL_INVALID_VALUE, \
+ "glGetIntegerv(0x%x)", (int) PNAME); \
return; \
}
#define CHECK_EXTENSION_F(EXTNAME, PNAME) \
if (!ctx->Extensions.EXTNAME) { \
- char s[100]; \
- sprintf(s, "glGetFloatv(0x%x)", (int) PNAME); \
- _mesa_error(ctx, GL_INVALID_VALUE, s); \
+ _mesa_error(ctx, GL_INVALID_VALUE, \
+ "glGetFloatv(0x%x)", (int) PNAME); \
return; \
}
#define CHECK_EXTENSION_D(EXTNAME, PNAME) \
if (!ctx->Extensions.EXTNAME) { \
- char s[100]; \
- sprintf(s, "glGetDoublev(0x%x)", (int) PNAME); \
- _mesa_error(ctx, GL_INVALID_VALUE, s); \
+ _mesa_error(ctx, GL_INVALID_VALUE, \
+ "glGetDoublev(0x%x)", (int) PNAME); \
return; \
}
@@ -1471,11 +1467,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
break;
default:
- {
- char s[100];
- sprintf(s, "glGetBooleanv(pname=0x%x)", pname);
- _mesa_error( ctx, GL_INVALID_ENUM, s );
- }
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv(pname=0x%x)", pname);
}
}
@@ -2829,11 +2821,7 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
break;
default:
- {
- char s[100];
- sprintf(s, "glGetDoublev(pname=0x%x)", pname);
- _mesa_error( ctx, GL_INVALID_ENUM, s );
- }
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetDoublev(pname=0x%x)", pname);
}
}
@@ -4163,11 +4151,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
break;
default:
- {
- char s[100];
- sprintf(s, "glGetFloatv(0x%x)", pname);
- _mesa_error(ctx, GL_INVALID_ENUM, s);
- }
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv(0x%x)", pname);
}
}
@@ -5542,11 +5526,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
break;
default:
- {
- char s[100];
- sprintf(s, "glGetIntegerv(pname=0x%x)", pname);
- _mesa_error( ctx, GL_INVALID_ENUM, s );
- }
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv(pname=0x%x)", pname);
}
}
diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c
index 03050e7fc69..e5b82d4d886 100644
--- a/src/mesa/main/hash.c
+++ b/src/mesa/main/hash.c
@@ -1,4 +1,4 @@
-/* $Id: hash.c,v 1.11 2001/11/02 00:57:04 brianp Exp $ */
+/* $Id: hash.c,v 1.12 2002/06/29 19:48:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -31,6 +31,7 @@
#include "glheader.h"
#include "glthread.h"
#include "hash.h"
+#include "context.h"
#include "mem.h"
#endif
@@ -237,7 +238,7 @@ void _mesa_HashPrint(const struct _mesa_HashTable *table)
for (i=0;i<TABLE_SIZE;i++) {
const struct HashEntry *entry = table->Table[i];
while (entry) {
- printf("%u %p\n", entry->Key, entry->Data);
+ _mesa_debug(NULL, "%u %p\n", entry->Key, entry->Data);
entry = entry->Next;
}
}
@@ -294,17 +295,19 @@ int main(int argc, char *argv[])
int a, b, c;
struct HashTable *t;
- printf("&a = %p\n", &a);
- printf("&b = %p\n", &b);
+ _mesa_printf("&a = %p\n", &a);
+ _mesa_printf("&b = %p\n", &b);
t = _mesa_NewHashTable();
_mesa_HashInsert(t, 501, &a);
_mesa_HashInsert(t, 10, &c);
_mesa_HashInsert(t, 0xfffffff8, &b);
_mesa_HashPrint(t);
- printf("Find 501: %p\n", _mesa_HashLookup(t,501));
- printf("Find 1313: %p\n", _mesa_HashLookup(t,1313));
- printf("Find block of 100: %d\n", _mesa_HashFindFreeKeyBlock(t, 100));
+
+ _mesa_printf("Find 501: %p\n", _mesa_HashLookup(t,501));
+ _mesa_printf("Find 1313: %p\n", _mesa_HashLookup(t,1313));
+ _mesa_printf("Find block of 100: %d\n", _mesa_HashFindFreeKeyBlock(t, 100));
+
_mesa_DeleteHashTable(t);
return 0;
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 40c02c246c1..dbe88a9724e 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -1,4 +1,4 @@
-/* $Id: imports.c,v 1.14 2002/06/18 08:35:25 joukj Exp $ */
+/* $Id: imports.c,v 1.15 2002/06/29 19:48:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -26,31 +26,24 @@
/*
- * Imports are functions which the device driver or window system or
+ * Imports are services which the device driver or window system or
* operating system provides to the core renderer. The core renderer (Mesa)
* will call these functions in order to do memory allocation, simple I/O,
* etc.
*
- * 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.
+ * Some drivers will want to override/replace this file with something
+ * specialized, but most Mesa drivers will be able to call
+ *_mesa_init_default_imports() and go with what's here.
*
- * A server-side GL renderer will likely not use these functions since
- * the renderer should use the XFree86-wrapped system calls.
- */
-
-/*
- * 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...
+ * Eventually, I'd like to move most of the stuff in glheader.h and mem.[ch]
+ * into imports.[ch]. Then we'll really have one, single place where
+ * all OS-related dependencies are isolated.
*/
-
#include "glheader.h"
#include "mtypes.h"
+#include "context.h"
#include "imports.h"
#include "mem.h"
@@ -79,46 +72,49 @@ _mesa_Free(__GLcontext *gc, void *addr)
FREE(addr);
}
+
/* Must be before '#undef getenv' for inclusion in XFree86.
*/
static char * CAPI
_mesa_getenv(__GLcontext *gc, const char *var)
{
(void) gc;
+/* Whacko XFree86 macro:
+ */
+#ifdef getenv
+#undef getenv
+#endif
return getenv(var);
}
+
static void
-_mesa_warning(__GLcontext *gc, char *str)
+warning(__GLcontext *gc, char *str)
{
GLboolean debug;
#ifdef DEBUG
debug = GL_TRUE;
#else
-/* Whacko XFree86 macro:
- */
-#ifdef getenv
-#undef getenv
-#endif
- if (gc->imports.getenv(gc, "MESA_DEBUG")) {
+ if (_mesa_getenv(gc "MESA_DEBUG"))
debug = GL_TRUE;
- }
- else {
+ else
debug = GL_FALSE;
- }
#endif
if (debug) {
fprintf(stderr, "Mesa warning: %s\n", str);
}
}
-static void
+
+void
_mesa_fatal(__GLcontext *gc, char *str)
{
+ (void) gc;
fprintf(stderr, "%s\n", str);
abort();
}
+
static int CAPI
_mesa_atoi(__GLcontext *gc, const char *str)
{
@@ -126,7 +122,8 @@ _mesa_atoi(__GLcontext *gc, const char *str)
return atoi(str);
}
-static int CAPI
+
+int CAPI
_mesa_sprintf(__GLcontext *gc, char *str, const char *fmt, ...)
{
int r;
@@ -137,18 +134,21 @@ _mesa_sprintf(__GLcontext *gc, char *str, const char *fmt, ...)
return r;
}
+
static void * CAPI
_mesa_fopen(__GLcontext *gc, const char *path, const char *mode)
{
return fopen(path, mode);
}
+
static int CAPI
_mesa_fclose(__GLcontext *gc, void *stream)
{
return fclose((FILE *) stream);
}
+
static int CAPI
_mesa_fprintf(__GLcontext *gc, void *stream, const char *fmt, ...)
{
@@ -160,6 +160,7 @@ _mesa_fprintf(__GLcontext *gc, void *stream, const char *fmt, ...)
return r;
}
+
/* XXX this really is driver-specific and can't be here */
static __GLdrawablePrivate *
_mesa_GetDrawablePrivate(__GLcontext *gc)
@@ -168,6 +169,160 @@ _mesa_GetDrawablePrivate(__GLcontext *gc)
}
+
+void
+_mesa_warning(__GLcontext *gc, const char *fmtString, ...)
+{
+ char str[1000];
+ va_list args;
+ va_start( args, fmtString );
+ (void) vsprintf( str, fmtString, args );
+ va_end( args );
+ warning(gc, str);
+}
+
+
+/*
+ * This function is called when the Mesa user has stumbled into a code
+ * path which may not be implemented fully or correctly.
+ */
+void
+_mesa_problem( const GLcontext *ctx, const char *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");
+#else
+ fprintf( stderr, "Please report to the Mesa bug database at www.mesa3d.org\n" );
+#endif
+ }
+}
+
+
+/*
+ * If in debug mode, print error message to stdout.
+ * Also, record the error code by calling _mesa_record_error().
+ * Input: ctx - the GL context
+ * error - the error value
+ * fmtString - printf-style format string, followed by optional args
+ */
+void
+_mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... )
+{
+ const char *debugEnv;
+ GLboolean debug;
+
+ debugEnv = _mesa_getenv(ctx, "MESA_DEBUG");
+
+#ifdef DEBUG
+ if (debugEnv && strstr(debugEnv, "silent"))
+ debug = GL_FALSE;
+ else
+ debug = GL_TRUE;
+#else
+ if (debugEnv)
+ debug = GL_TRUE;
+ else
+ debug = GL_FALSE;
+#endif
+
+ if (debug) {
+ va_list args;
+ char where[1000];
+ const char *errstr;
+
+ va_start( args, fmtString );
+ vsprintf( where, fmtString, args );
+ va_end( args );
+
+ switch (error) {
+ case GL_NO_ERROR:
+ errstr = "GL_NO_ERROR";
+ break;
+ case GL_INVALID_VALUE:
+ errstr = "GL_INVALID_VALUE";
+ break;
+ case GL_INVALID_ENUM:
+ errstr = "GL_INVALID_ENUM";
+ break;
+ case GL_INVALID_OPERATION:
+ errstr = "GL_INVALID_OPERATION";
+ break;
+ case GL_STACK_OVERFLOW:
+ errstr = "GL_STACK_OVERFLOW";
+ break;
+ case GL_STACK_UNDERFLOW:
+ errstr = "GL_STACK_UNDERFLOW";
+ break;
+ case GL_OUT_OF_MEMORY:
+ errstr = "GL_OUT_OF_MEMORY";
+ break;
+ case GL_TABLE_TOO_LARGE:
+ errstr = "GL_TABLE_TOO_LARGE";
+ break;
+ default:
+ errstr = "unknown";
+ break;
+ }
+ _mesa_debug(ctx, "Mesa user error: %s in %s\n", errstr, where);
+ }
+
+ _mesa_record_error(ctx, error);
+}
+
+
+/*
+ * Call this to report debug information. Uses stderr.
+ */
+void
+_mesa_debug( const GLcontext *ctx, const char *fmtString, ... )
+{
+ char s[1000];
+ va_list args;
+ va_start(args, fmtString);
+ vsprintf(s, fmtString, args);
+ if (ctx)
+ (void) ctx->imports.fprintf( (__GLcontext *) ctx, stderr, s );
+ else
+ fprintf( stderr, s );
+ va_end(args);
+}
+
+
+/*
+ * A wrapper for printf. Uses stdout.
+ */
+void
+_mesa_printf( const GLcontext *ctx, const char *fmtString, ... )
+{
+ char s[1000];
+ va_list args;
+ va_start( args, fmtString );
+ vsprintf(s, fmtString, args);
+ if (ctx)
+ (void) ctx->imports.fprintf( (__GLcontext *) ctx, stdout, s );
+ else
+ printf( s );
+ va_end( args );
+}
+
+
+/*
+ * Initialize a __GLimports object to point to the functions in
+ * this file. This is to be called from device drivers.
+ * Input: imports - the object to init
+ * driverCtx - pointer to device driver-specific data
+ */
void
_mesa_init_default_imports(__GLimports *imports, void *driverCtx)
{
@@ -175,7 +330,7 @@ _mesa_init_default_imports(__GLimports *imports, void *driverCtx)
imports->calloc = _mesa_Calloc;
imports->realloc = _mesa_Realloc;
imports->free = _mesa_Free;
- imports->warning = _mesa_warning;
+ imports->warning = warning;
imports->fatal = _mesa_fatal;
imports->getenv = _mesa_getenv;
imports->atoi = _mesa_atoi;
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 95bcf312a97..2a19ff81d1a 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -1,4 +1,4 @@
-/* $Id: imports.h,v 1.3 2002/06/13 04:28:29 brianp Exp $ */
+/* $Id: imports.h,v 1.4 2002/06/29 19:48:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -32,6 +32,28 @@
#include "glheader.h"
+extern int CAPI
+_mesa_sprintf(__GLcontext *gc, char *str, const char *fmt, ...);
+
+extern void
+_mesa_warning(__GLcontext *gc, const char *fmtString, ...);
+
+extern void
+_mesa_fatal(__GLcontext *gc, char *str);
+
+extern void
+_mesa_problem( const __GLcontext *ctx, const char *s );
+
+extern void
+_mesa_error( __GLcontext *ctx, GLenum error, const char *fmtString, ... );
+
+extern void
+_mesa_debug( const __GLcontext *ctx, const char *fmtString, ... );
+
+extern void
+_mesa_printf( const __GLcontext *ctx, const char *fmtString, ... );
+
+
extern void
_mesa_init_default_imports(__GLimports *imports, void *driverCtx);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 366d477eb81..0b73a431b5a 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1,4 +1,4 @@
-/* $Id: mtypes.h,v 1.81 2002/06/18 16:53:46 brianp Exp $ */
+/* $Id: mtypes.h,v 1.82 2002/06/29 19:48:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1845,7 +1845,7 @@ enum _debug {
#define FLUSH_VERTICES(ctx, newstate) \
do { \
if (MESA_VERBOSE & VERBOSE_STATE) \
- fprintf(stderr, "FLUSH_VERTICES in %s\n", __FUNCTION__); \
+ _mesa_debug(ctx, "FLUSH_VERTICES in %s\n", __FUNCTION__); \
if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \
ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \
ctx->NewState |= newstate; \
@@ -1854,7 +1854,7 @@ do { \
#define FLUSH_CURRENT(ctx, newstate) \
do { \
if (MESA_VERBOSE & VERBOSE_STATE) \
- fprintf(stderr, "FLUSH_CURRENT in %s\n", __FUNCTION__); \
+ _mesa_debug(ctx, "FLUSH_CURRENT in %s\n", __FUNCTION__); \
if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \
ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \
ctx->NewState |= newstate; \
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index ce145d800bc..65ad6d2a871 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -1,4 +1,4 @@
-/* $Id: texformat.c,v 1.12 2002/06/15 02:38:16 brianp Exp $ */
+/* $Id: texformat.c,v 1.13 2002/06/29 19:48:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -739,7 +739,7 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
default:
_mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
- printf("intformat = %d %x\n", internalFormat, internalFormat);
+ _mesa_debug(ctx, "intformat = %d %x\n", internalFormat, internalFormat);
return NULL;
}
}
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 2ad0df9d6ba..2ff9d891219 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1,4 +1,4 @@
-/* $Id: teximage.c,v 1.109 2002/06/15 03:03:09 brianp Exp $ */
+/* $Id: teximage.c,v 1.110 2002/06/29 19:48:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -55,8 +55,8 @@
*/
-#ifdef DEBUG
-static void PrintTexture(const struct gl_texture_image *img)
+#if 0
+static void PrintTexture(GLcontext *ctx, const struct gl_texture_image *img)
{
#if CHAN_TYPE == GL_FLOAT
_mesa_problem(NULL, "PrintTexture doesn't support float channels");
@@ -65,7 +65,7 @@ static void PrintTexture(const struct gl_texture_image *img)
const GLchan *data = (const GLchan *) img->Data;
if (!data) {
- printf("No texture data\n");
+ _mesa_printf(ctx, "No texture data\n");
return;
}
@@ -93,16 +93,16 @@ static void PrintTexture(const struct gl_texture_image *img)
for (i = 0; i < img->Height; i++) {
for (j = 0; j < img->Width; j++) {
if (c==1)
- printf("%02x ", data[0]);
+ _mesa_printf(ctx, "%02x ", data[0]);
else if (c==2)
- printf("%02x%02x ", data[0], data[1]);
+ _mesa_printf(ctx, "%02x%02x ", data[0], data[1]);
else if (c==3)
- printf("%02x%02x%02x ", data[0], data[1], data[2]);
+ _mesa_printf(ctx, "%02x%02x%02x ", data[0], data[1], data[2]);
else if (c==4)
- printf("%02x%02x%02x%02x ", data[0], data[1], data[2], data[3]);
+ _mesa_printf(ctx, "%02x%02x%02x%02x ", data[0], data[1], data[2], data[3]);
data += c;
}
- printf("\n");
+ _mesa_printf(ctx, "\n");
}
#endif
}
@@ -769,9 +769,8 @@ texture_error_check( GLcontext *ctx, GLenum target,
/* Border */
if (border != 0 && border != 1) {
if (!isProxy) {
- char message[100];
- sprintf(message, "glTexImage%dD(border=%d)", dimensions, border);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTexImage%dD(border=%d)", dimensions, border);
}
return GL_TRUE;
}
@@ -785,9 +784,8 @@ texture_error_check( GLcontext *ctx, GLenum target,
target == GL_PROXY_TEXTURE_RECTANGLE_NV) {
if (width < 1 || width > ctx->Const.MaxTextureRectSize) {
if (!isProxy) {
- char message[100];
- sprintf(message, "glTexImage%dD(width=%d)", dimensions, width);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTexImage%dD(width=%d)", dimensions, width);
}
return GL_TRUE;
}
@@ -795,9 +793,8 @@ texture_error_check( GLcontext *ctx, GLenum target,
else if (width < 2 * border || width > 2 + maxTextureSize
|| logbase2( width - 2 * border ) < 0) {
if (!isProxy) {
- char message[100];
- sprintf(message, "glTexImage%dD(width=%d)", dimensions, width);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTexImage%dD(width=%d)", dimensions, width);
}
return GL_TRUE;
}
@@ -807,9 +804,8 @@ texture_error_check( GLcontext *ctx, GLenum target,
target == GL_PROXY_TEXTURE_RECTANGLE_NV) {
if (height < 1 || height > ctx->Const.MaxTextureRectSize) {
if (!isProxy) {
- char message[100];
- sprintf(message, "glTexImage%dD(height=%d)", dimensions, height);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTexImage%dD(height=%d)", dimensions, height);
}
return GL_TRUE;
}
@@ -818,9 +814,8 @@ texture_error_check( GLcontext *ctx, GLenum target,
if (height < 2 * border || height > 2 + maxTextureSize
|| logbase2( height - 2 * border ) < 0) {
if (!isProxy) {
- char message[100];
- sprintf(message, "glTexImage%dD(height=%d)", dimensions, height);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTexImage%dD(height=%d)", dimensions, height);
}
return GL_TRUE;
}
@@ -842,9 +837,8 @@ texture_error_check( GLcontext *ctx, GLenum target,
if (depth < 2 * border || depth > 2 + maxTextureSize
|| logbase2( depth - 2 * border ) < 0) {
if (!isProxy) {
- char message[100];
- sprintf(message, "glTexImage3D(depth=%d)", depth );
- _mesa_error( ctx, GL_INVALID_VALUE, message );
+ _mesa_error( ctx, GL_INVALID_VALUE,
+ "glTexImage3D(depth=%d)", depth );
}
return GL_TRUE;
}
@@ -855,18 +849,16 @@ texture_error_check( GLcontext *ctx, GLenum target,
target == GL_PROXY_TEXTURE_RECTANGLE_NV) {
if (level != 0) {
if (!isProxy) {
- char message[100];
- sprintf(message, "glTexImage2D(level=%d)", level);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTexImage2D(level=%d)", level);
}
return GL_TRUE;
}
}
else if (level < 0 || level >= maxLevels) {
if (!isProxy) {
- char message[100];
- sprintf(message, "glTexImage%dD(level=%d)", dimensions, level);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTexImage%dD(level=%d)", dimensions, level);
}
return GL_TRUE;
}
@@ -883,10 +875,9 @@ texture_error_check( GLcontext *ctx, GLenum target,
iformat = _mesa_base_tex_format( ctx, internalFormat );
if (iformat < 0) {
if (!isProxy) {
- char message[100];
- sprintf(message, "glTexImage%dD(internalFormat=0x%x)", dimensions,
- internalFormat);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTexImage%dD(internalFormat=0x%x)",
+ dimensions, internalFormat);
}
return GL_TRUE;
}
@@ -899,9 +890,8 @@ texture_error_check( GLcontext *ctx, GLenum target,
* is a type/format mismatch. See 1.2 spec page 94, sec 3.6.4.
*/
if (!isProxy) {
- char message[100];
- sprintf(message, "glTexImage%dD(format or type)", dimensions);
- _mesa_error(ctx, GL_INVALID_OPERATION, message);
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTexImage%dD(format or type)", dimensions);
}
return GL_TRUE;
}
@@ -970,28 +960,22 @@ subtexture_error_check( GLcontext *ctx, GLuint dimensions,
ASSERT(maxLevels > 0);
if (level < 0 || level >= maxLevels) {
- char message[100];
- sprintf(message, "glTexSubImage2D(level=%d)", level);
- _mesa_error(ctx, GL_INVALID_ENUM, message);
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage2D(level=%d)", level);
return GL_TRUE;
}
if (width < 0) {
- char message[100];
- sprintf(message, "glTexSubImage%dD(width=%d)", dimensions, width);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTexSubImage%dD(width=%d)", dimensions, width);
return GL_TRUE;
}
if (height < 0 && dimensions > 1) {
- char message[100];
- sprintf(message, "glTexSubImage%dD(height=%d)", dimensions, height);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTexSubImage%dD(height=%d)", dimensions, height);
return GL_TRUE;
}
if (depth < 0 && dimensions > 2) {
- char message[100];
- sprintf(message, "glTexSubImage%dD(depth=%d)", dimensions, depth);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(depth=%d)", dimensions, depth);
return GL_TRUE;
}
@@ -1034,9 +1018,8 @@ subtexture_error_check( GLcontext *ctx, GLuint dimensions,
compressed = is_compressed_format(ctx, destTex->IntFormat);
if (!compressed && !_mesa_is_legal_format_and_type(format, type)) {
- char message[100];
- sprintf(message, "glTexSubImage%dD(format or type)", dimensions);
- _mesa_error(ctx, GL_INVALID_ENUM, message);
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexSubImage%dD(format or type)", dimensions);
return GL_TRUE;
}
@@ -1113,18 +1096,16 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions,
/* Border */
if (border != 0 && border != 1) {
- char message[100];
- sprintf(message, "glCopyTexImage%dD(border)", dimensions);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexImage%dD(border)", dimensions);
return GL_TRUE;
}
/* Width */
if (width < 2 * border || width > 2 + maxTextureSize
|| logbase2( width - 2 * border ) < 0) {
- char message[100];
- sprintf(message, "glCopyTexImage%dD(width=%d)", dimensions, width);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexImage%dD(width=%d)", dimensions, width);
return GL_TRUE;
}
@@ -1132,9 +1113,8 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions,
if (dimensions >= 2) {
if (height < 2 * border || height > 2 + maxTextureSize
|| logbase2( height - 2 * border ) < 0) {
- char message[100];
- sprintf(message, "glCopyTexImage%dD(height=%d)", dimensions, height);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexImage%dD(height=%d)", dimensions, height);
return GL_TRUE;
}
}
@@ -1150,17 +1130,15 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions,
/* Level */
if (level < 0 || level >= maxLevels) {
- char message[100];
- sprintf(message, "glCopyTexImage%dD(level=%d)", dimensions, level);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexImage%dD(level=%d)", dimensions, level);
return GL_TRUE;
}
iformat = _mesa_base_tex_format(ctx, internalFormat);
if (iformat < 0) {
- char message[100];
- sprintf(message, "glCopyTexImage%dD(internalFormat)", dimensions);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexImage%dD(internalFormat)", dimensions);
return GL_TRUE;
}
@@ -1216,72 +1194,62 @@ copytexsubimage_error_check( GLcontext *ctx, GLuint dimensions,
ASSERT(maxLevels > 0);
if (level < 0 || level >= maxLevels) {
- char message[100];
- sprintf(message, "glCopyTexSubImage%dD(level=%d)", dimensions, level);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(level=%d)", dimensions, level);
return GL_TRUE;
}
if (width < 0) {
- char message[100];
- sprintf(message, "glCopyTexSubImage%dD(width=%d)", dimensions, width);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(width=%d)", dimensions, width);
return GL_TRUE;
}
if (dimensions > 1 && height < 0) {
- char message[100];
- sprintf(message, "glCopyTexSubImage%dD(height=%d)", dimensions, height);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(height=%d)", dimensions, height);
return GL_TRUE;
}
teximage = _mesa_select_tex_image(ctx, texUnit, target, level);
if (!teximage) {
- char message[100];
- sprintf(message, "glCopyTexSubImage%dD(undefined texture)", dimensions);
- _mesa_error(ctx, GL_INVALID_OPERATION, message);
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCopyTexSubImage%dD(undefined texture)", dimensions);
return GL_TRUE;
}
if (xoffset < -((GLint)teximage->Border)) {
- char message[100];
- sprintf(message, "glCopyTexSubImage%dD(xoffset=%d)", dimensions, xoffset);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(xoffset=%d)", dimensions, xoffset);
return GL_TRUE;
}
if (xoffset + width > (GLint) (teximage->Width + teximage->Border)) {
- char message[100];
- sprintf(message, "glCopyTexSubImage%dD(xoffset+width)", dimensions);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(xoffset+width)", dimensions);
return GL_TRUE;
}
if (dimensions > 1) {
if (yoffset < -((GLint)teximage->Border)) {
- char message[100];
- sprintf(message, "glCopyTexSubImage%dD(yoffset=%d)", dimensions, yoffset);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(yoffset=%d)", dimensions, yoffset);
return GL_TRUE;
}
/* NOTE: we're adding the border here, not subtracting! */
if (yoffset + height > (GLint) (teximage->Height + teximage->Border)) {
- char message[100];
- sprintf(message, "glCopyTexSubImage%dD(yoffset+height)", dimensions);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(yoffset+height)", dimensions);
return GL_TRUE;
}
}
if (dimensions > 2) {
if (zoffset < -((GLint)teximage->Border)) {
- char message[100];
- sprintf(message, "glCopyTexSubImage%dD(zoffset)", dimensions);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(zoffset)", dimensions);
return GL_TRUE;
}
if (zoffset > (GLint) (teximage->Depth + teximage->Border)) {
- char message[100];
- sprintf(message, "glCopyTexSubImage%dD(zoffset+depth)", dimensions);
- _mesa_error(ctx, GL_INVALID_VALUE, message);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(zoffset+depth)", dimensions);
return GL_TRUE;
}
}
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 7d4b402d28e..909492cd499 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1,4 +1,4 @@
-/* $Id: texobj.c,v 1.56 2002/06/17 23:36:31 brianp Exp $ */
+/* $Id: texobj.c,v 1.57 2002/06/29 19:48:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -219,7 +219,7 @@ _mesa_copy_texture_object( struct gl_texture_object *dest,
static void
incomplete(const struct gl_texture_object *t, const char *why)
{
- printf("Texture Obj %d incomplete because: %s\n", t->Name, why);
+ _mesa_printf("Texture Obj %d incomplete because: %s\n", t->Name, why);
}
#else
#define incomplete(a, b)
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 8f4f3631ea7..e0d3a4ae20d 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -1,4 +1,4 @@
-/* $Id: texstate.c,v 1.76 2002/06/17 23:36:31 brianp Exp $ */
+/* $Id: texstate.c,v 1.77 2002/06/29 19:48:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -131,11 +131,7 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
ASSERT_OUTSIDE_BEGIN_END(ctx);
#define TE_ERROR(errCode, msg, value) \
- { \
- char s[100]; \
- sprintf(s, msg, _mesa_lookup_enum_by_nr(value)); \
- _mesa_error(ctx, errCode, s); \
- }
+ _mesa_error(ctx, errCode, msg, _mesa_lookup_enum_by_nr(value));
if (target == GL_TEXTURE_ENV) {
switch (pname) {
@@ -1347,11 +1343,8 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
break;
default:
- {
- char s[100];
- sprintf(s, "glTexParameter(pname=0x%x)", pname);
- _mesa_error( ctx, GL_INVALID_ENUM, s);
- }
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexParameter(pname=0x%x)", pname);
return;
}
@@ -1454,7 +1447,12 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
case GL_PROXY_TEXTURE_3D:
maxLevels = ctx->Const.Max3DTextureLevels;
break;
- case GL_TEXTURE_CUBE_MAP_ARB:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
maxLevels = ctx->Const.MaxCubeTextureLevels;
break;
@@ -1463,7 +1461,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
maxLevels = 1;
break;
default:
- _mesa_problem(ctx, "bad target in _mesa_GetTexLevelParameter");
+ _mesa_printf(ctx, "bad target in _mesa_GetTexLevelParameter (0x%x)", target);
return;
}
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 7d37bcb00fd..674de7af52c 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -1,4 +1,4 @@
-/* $Id: texstore.c,v 1.37 2002/06/15 03:03:09 brianp Exp $ */
+/* $Id: texstore.c,v 1.38 2002/06/29 19:48:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1470,7 +1470,7 @@ make_3d_mipmap(const struct gl_texture_format *format, GLint border,
*/
/*
- printf("mip3d %d x %d x %d -> %d x %d x %d\n",
+ _mesa_printf("mip3d %d x %d x %d -> %d x %d x %d\n",
srcWidth, srcHeight, srcDepth, dstWidth, dstHeight, dstDepth);
*/
diff --git a/src/mesa/main/texutil_tmp.h b/src/mesa/main/texutil_tmp.h
index 3d2ecd9fd02..7a70a55d024 100644
--- a/src/mesa/main/texutil_tmp.h
+++ b/src/mesa/main/texutil_tmp.h
@@ -1,4 +1,4 @@
-/* $Id: texutil_tmp.h,v 1.9 2002/02/21 15:12:31 brianp Exp $ */
+/* $Id: texutil_tmp.h,v 1.10 2002/06/29 19:48:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -27,11 +27,15 @@
* Gareth Hughes <[email protected]>
*/
+
+
/*
* NOTE: All 3D teximage code is untested and most definitely broken...
*/
+
+
#define DST_TEXEL_BYTES (4 / DST_TEXELS_PER_DWORD)
#define DST_ROW_BYTES (convert->width * DST_TEXEL_BYTES)
#define DST_ROW_STRIDE (convert->dstImageWidth * DST_TEXEL_BYTES)
@@ -51,7 +55,7 @@ TAG(texsubimage2d)( struct gl_texture_convert *convert )
convert->xoffset) * DST_TEXEL_BYTES);
#if DEBUG_TEXUTIL
- fprintf( stderr, __FUNCTION__ "\n" );
+ _mesa_debug( NULL, __FUNCTION__ "\n" );
#endif
#ifdef CONVERT_DIRECT
@@ -87,7 +91,7 @@ TAG(texsubimage3d)( struct gl_texture_convert *convert )
convert->yoffset) * convert->width +
convert->xoffset) * DST_TEXEL_BYTES);
#if DEBUG_TEXUTIL
- fprintf( stderr, __FUNCTION__ "\n" );
+ _mesa_debug( NULL, __FUNCTION__ "\n" );
#endif
#ifdef CONVERT_DIRECT
@@ -130,11 +134,11 @@ TAG(texsubimage2d_stride)( struct gl_texture_convert *convert )
adjust = convert->dstImageWidth - convert->width;
#if DEBUG_TEXUTIL
- fprintf( stderr, __FUNCTION__ ":\n" );
- fprintf( stderr, " x=%d y=%d w=%d h=%d s=%d\n",
+ _mesa_debug( NULL, __FUNCTION__ ":\n" );
+ _mesa_debug( NULL, " x=%d y=%d w=%d h=%d s=%d\n",
convert->xoffset, convert->yoffset, convert->width,
convert->height, convert->dstImageWidth );
- fprintf( stderr, " adjust=%d\n", adjust );
+ _mesa_debug( NULL, " adjust=%d\n", adjust );
#endif
for ( row = 0 ; row < convert->height ; row++ ) {
@@ -164,11 +168,11 @@ TAG(texsubimage3d_stride)( struct gl_texture_convert *convert )
adjust = convert->dstImageWidth - convert->width;
#if DEBUG_TEXUTIL
- fprintf( stderr, __FUNCTION__ ":\n" );
- fprintf( stderr, " x=%d y=%d w=%d h=%d s=%d\n",
+ _mesa_debug( NULL, __FUNCTION__ ":\n" );
+ _mesa_debug( NULL, " x=%d y=%d w=%d h=%d s=%d\n",
convert->xoffset, convert->yoffset, convert->width,
convert->height, convert->dstImageWidth );
- fprintf( stderr, " adjust=%d\n", adjust );
+ _mesa_debug( NULL, " adjust=%d\n", adjust );
#endif
for ( img = 0 ; img < convert->depth ; img++ ) {
@@ -203,7 +207,7 @@ TAG(texsubimage2d_unpack)( struct gl_texture_convert *convert )
GLint row, col;
#if DEBUG_TEXUTIL
- fprintf( stderr, __FUNCTION__ "\n" );
+ _mesa_debug( NULL, __FUNCTION__ "\n" );
#endif
if (convert->width & (DST_TEXELS_PER_DWORD - 1)) {
@@ -265,7 +269,7 @@ TAG(texsubimage3d_unpack)( struct gl_texture_convert *convert )
GLint row, col, img;
#if DEBUG_TEXUTIL
- fprintf( stderr, __FUNCTION__ "\n" );
+ _mesa_debug( NULL, __FUNCTION__ "\n" );
#endif
if (convert->width & (DST_TEXELS_PER_DWORD - 1)) {
@@ -343,11 +347,11 @@ TAG(texsubimage2d_stride_unpack)( struct gl_texture_convert *convert )
adjust = convert->dstImageWidth - convert->width;
#if DEBUG_TEXUTIL
- fprintf( stderr, __FUNCTION__ ":\n" );
- fprintf( stderr, " x=%d y=%d w=%d h=%d s=%d\n",
+ _mesa_debug( NULL, __FUNCTION__ ":\n" );
+ _mesa_debug( NULL, " x=%d y=%d w=%d h=%d s=%d\n",
convert->xoffset, convert->yoffset, convert->width,
convert->height, convert->dstImageWidth );
- fprintf( stderr, " adjust=%d\n", adjust );
+ _mesa_debug( NULL, " adjust=%d\n", adjust );
#endif
for ( row = 0 ; row < convert->height ; row++ ) {
@@ -396,11 +400,11 @@ TAG(texsubimage3d_stride_unpack)( struct gl_texture_convert *convert )
adjust = convert->dstImageWidth - convert->width;
#if DEBUG_TEXUTIL
- fprintf( stderr, __FUNCTION__ ":\n" );
- fprintf( stderr, " x=%d y=%d w=%d h=%d s=%d\n",
+ _mesa_debug( NULL, __FUNCTION__ ":\n" );
+ _mesa_debug( NULL, " x=%d y=%d w=%d h=%d s=%d\n",
convert->xoffset, convert->yoffset, convert->width,
convert->height, convert->dstImageWidth );
- fprintf( stderr, " adjust=%d\n", adjust );
+ _mesa_debug( NULL, " adjust=%d\n", adjust );
#endif
for ( img = 0 ; img < convert->depth ; img++ ) {
diff --git a/src/mesa/main/vtxfmt.c b/src/mesa/main/vtxfmt.c
index 14b8e8381aa..44e387f92c5 100644
--- a/src/mesa/main/vtxfmt.c
+++ b/src/mesa/main/vtxfmt.c
@@ -1,4 +1,4 @@
-/* $Id: vtxfmt.c,v 1.11 2002/04/09 16:56:50 keithw Exp $ */
+/* $Id: vtxfmt.c,v 1.12 2002/06/29 19:48:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -61,7 +61,7 @@
tnl->SwapCount++; \
\
if ( 0 ) \
- fprintf( stderr, " swapping gl" #FUNC"...\n" ); \
+ _mesa_debug(ctx, " swapping gl" #FUNC"...\n" ); \
\
/* Install the tnl function pointer. */ \
ctx->Exec->FUNC = tnl->Current->FUNC; \