summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-10-29 09:25:16 -0600
committerBrian Paul <[email protected]>2009-10-29 10:50:26 -0600
commit67df4fb56bcb72eddcfc187454d95b663cc43578 (patch)
tree2be28b17948b485437d40ddc0011c3aabcebd586
parentd580c0c8f7cad69b808118ef2aa6161f62f160d8 (diff)
mesa: move, clean-up _mesa_print_texture()
-rw-r--r--src/mesa/main/debug.c61
-rw-r--r--src/mesa/main/debug.h3
-rw-r--r--src/mesa/main/teximage.c57
3 files changed, 64 insertions, 57 deletions
diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c
index ee8cc29301d..a42113edcac 100644
--- a/src/mesa/main/debug.c
+++ b/src/mesa/main/debug.c
@@ -574,3 +574,64 @@ _mesa_dump_stencil_buffer(const char *filename)
_mesa_free(buf);
_mesa_free(buf2);
}
+
+
+/**
+ * Quick and dirty function to "print" a texture to stdout.
+ */
+void
+_mesa_print_texture(GLcontext *ctx, const struct gl_texture_image *img)
+{
+#if CHAN_TYPE != GL_UNSIGNED_BYTE
+ _mesa_problem(NULL, "PrintTexture not supported");
+#else
+ GLuint i, j, c;
+ const GLubyte *data = (const GLubyte *) img->Data;
+
+ if (!data) {
+ _mesa_printf("No texture data\n");
+ return;
+ }
+
+ /* XXX add more formats or make into a new format utility function */
+ switch (img->TexFormat) {
+ case MESA_FORMAT_A8:
+ case MESA_FORMAT_L8:
+ case MESA_FORMAT_I8:
+ case MESA_FORMAT_CI8:
+ c = 1;
+ break;
+ case MESA_FORMAT_AL88:
+ case MESA_FORMAT_AL88_REV:
+ c = 2;
+ break;
+ case MESA_FORMAT_RGB888:
+ case MESA_FORMAT_BGR888:
+ c = 3;
+ break;
+ case MESA_FORMAT_RGBA8888:
+ case MESA_FORMAT_ARGB8888:
+ c = 4;
+ break;
+ default:
+ _mesa_problem(NULL, "error in PrintTexture\n");
+ return;
+ }
+
+ for (i = 0; i < img->Height; i++) {
+ for (j = 0; j < img->Width; j++) {
+ if (c==1)
+ _mesa_printf("%02x ", data[0]);
+ else if (c==2)
+ _mesa_printf("%02x%02x ", data[0], data[1]);
+ else if (c==3)
+ _mesa_printf("%02x%02x%02x ", data[0], data[1], data[2]);
+ else if (c==4)
+ _mesa_printf("%02x%02x%02x%02x ", data[0], data[1], data[2], data[3]);
+ data += (img->RowStride - img->Width) * c;
+ }
+ /* XXX use img->ImageStride here */
+ _mesa_printf("\n");
+ }
+#endif
+}
diff --git a/src/mesa/main/debug.h b/src/mesa/main/debug.h
index d12ea602dd7..0449cb1798a 100644
--- a/src/mesa/main/debug.h
+++ b/src/mesa/main/debug.h
@@ -75,4 +75,7 @@ _mesa_dump_depth_buffer(const char *filename);
extern void
_mesa_dump_stencil_buffer(const char *filename);
+extern void
+_mesa_print_texture(GLcontext *ctx, const struct gl_texture_image *img);
+
#endif
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 13053ce9ba2..73a555a1816 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -82,63 +82,6 @@ _mesa_free_texmemory(void *m)
}
-
-
-#if 0
-static void PrintTexture(GLcontext *ctx, const struct gl_texture_image *img)
-{
-#if CHAN_TYPE != GL_UNSIGNED_BYTE
- _mesa_problem(NULL, "PrintTexture not supported");
-#else
- GLuint i, j, c;
- const GLubyte *data = (const GLubyte *) img->Data;
-
- if (!data) {
- _mesa_printf("No texture data\n");
- return;
- }
-
- switch (img->Format) {
- case GL_ALPHA:
- case GL_LUMINANCE:
- case GL_INTENSITY:
- case GL_COLOR_INDEX:
- c = 1;
- break;
- case GL_LUMINANCE_ALPHA:
- c = 2;
- break;
- case GL_RGB:
- c = 3;
- break;
- case GL_RGBA:
- c = 4;
- break;
- default:
- _mesa_problem(NULL, "error in PrintTexture\n");
- return;
- }
-
- for (i = 0; i < img->Height; i++) {
- for (j = 0; j < img->Width; j++) {
- if (c==1)
- _mesa_printf("%02x ", data[0]);
- else if (c==2)
- _mesa_printf("%02x%02x ", data[0], data[1]);
- else if (c==3)
- _mesa_printf("%02x%02x%02x ", data[0], data[1], data[2]);
- else if (c==4)
- _mesa_printf("%02x%02x%02x%02x ", data[0], data[1], data[2], data[3]);
- data += (img->RowStride - img->Width) * c;
- }
- /* XXX use img->ImageStride here */
- _mesa_printf("\n");
- }
-#endif
-}
-#endif
-
-
/*
* Compute floor(log_base_2(n)).
* If n < 0 return -1.