diff options
Diffstat (limited to 'mesalib/src/mesa/main/debug.c')
-rw-r--r-- | mesalib/src/mesa/main/debug.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/mesalib/src/mesa/main/debug.c b/mesalib/src/mesa/main/debug.c index e336b077e..f82e32ed8 100644 --- a/mesalib/src/mesa/main/debug.c +++ b/mesalib/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.
*/
|