Mesa (master): mesa: added _mesa_dump_image() for debugging
Brian Paul
brianp at kemper.freedesktop.org
Thu Mar 24 22:04:20 UTC 2011
Module: Mesa
Branch: master
Commit: e1a9ef2304e9dc688b604fab889964922e76b6fe
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e1a9ef2304e9dc688b604fab889964922e76b6fe
Author: Brian Paul <brianp at vmware.com>
Date: Thu Mar 24 13:38:04 2011 -0600
mesa: added _mesa_dump_image() for debugging
---
src/mesa/main/debug.c | 24 ++++++++++++++++++++++++
src/mesa/main/debug.h | 4 ++++
2 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c
index 7888166..2a8fd08 100644
--- a/src/mesa/main/debug.c
+++ b/src/mesa/main/debug.c
@@ -251,6 +251,9 @@ write_ppm(const char *filename, const GLubyte *buffer, int width, int height,
}
fclose(f);
}
+ else {
+ fprintf(stderr, "Unable to create %s in write_ppm()\n", filename);
+ }
}
@@ -549,6 +552,27 @@ _mesa_dump_stencil_buffer(const char *filename)
}
+void
+_mesa_dump_image(const char *filename, const void *image, GLuint w, GLuint h,
+ GLenum format, GLenum type)
+{
+ GLboolean invert = GL_TRUE;
+
+ if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
+ write_ppm(filename, image, w, h, 4, 0, 1, 2, invert);
+ }
+ else if (format == GL_BGRA && type == GL_UNSIGNED_BYTE) {
+ write_ppm(filename, image, w, h, 4, 2, 1, 0, invert);
+ }
+ else if (format == GL_LUMINANCE_ALPHA && type == GL_UNSIGNED_BYTE) {
+ write_ppm(filename, image, w, h, 2, 1, 0, 0, invert);
+ }
+ else {
+ _mesa_problem(NULL, "Unsupported format/type in _mesa_dump_image()");
+ }
+}
+
+
/**
* Quick and dirty function to "print" a texture to stdout.
*/
diff --git a/src/mesa/main/debug.h b/src/mesa/main/debug.h
index 4968a9f..d7c53b6 100644
--- a/src/mesa/main/debug.h
+++ b/src/mesa/main/debug.h
@@ -85,6 +85,10 @@ extern void
_mesa_dump_stencil_buffer(const char *filename);
extern void
+_mesa_dump_image(const char *filename, const void *image, GLuint w, GLuint h,
+ GLenum format, GLenum type);
+
+extern void
_mesa_print_texture(struct gl_context *ctx, const struct gl_texture_image *img);
#endif
More information about the mesa-commit
mailing list