diff --git a/progs/demos/osdemo.c b/progs/demos/osdemo.c index 92bbd18491b..83f29af0703 100644 --- a/progs/demos/osdemo.c +++ b/progs/demos/osdemo.c @@ -1,4 +1,4 @@ -/* $Id: osdemo.c,v 1.2 2000/01/15 06:11:33 rjfrank Exp $ */ +/* $Id: osdemo.c,v 1.3 2000/03/06 23:56:21 brianp Exp $ */ /* * Demo of off-screen Mesa rendering @@ -17,27 +17,14 @@ */ -/* - * $Log: osdemo.c,v $ - * Revision 1.2 2000/01/15 06:11:33 rjfrank - * Added test for the occlusion test code. - * - * Revision 1.1.1.1 1999/08/19 00:55:40 jtg - * Imported sources - * - * Revision 3.0 1998/02/14 18:42:29 brianp - * initial rev - * - */ - - - #include #include #include "GL/osmesa.h" #include "GL/glut.h" +#define SAVE_TARGA + #define WIDTH 400 #define HEIGHT 400 @@ -143,16 +130,100 @@ static void render_image( void ) +static void +write_targa(const char *filename, const GLubyte *buffer, int width, int height) +{ + FILE *f = fopen( filename, "w" ); + if (f) { + int i, x, y; + const GLubyte *ptr = buffer; + printf ("osdemo, writing tga file \n"); + fputc (0x00, f); /* ID Length, 0 => No ID */ + fputc (0x00, f); /* Color Map Type, 0 => No color map included */ + fputc (0x02, f); /* Image Type, 2 => Uncompressed, True-color Image */ + fputc (0x00, f); /* Next five bytes are about the color map entries */ + fputc (0x00, f); /* 2 bytes Index, 2 bytes length, 1 byte size */ + fputc (0x00, f); + fputc (0x00, f); + fputc (0x00, f); + fputc (0x00, f); /* X-origin of Image */ + fputc (0x00, f); + fputc (0x00, f); /* Y-origin of Image */ + fputc (0x00, f); + fputc (WIDTH & 0xff, f); /* Image Width */ + fputc ((WIDTH>>8) & 0xff, f); + fputc (HEIGHT & 0xff, f); /* Image Height */ + fputc ((HEIGHT>>8) & 0xff, f); + fputc (0x18, f); /* Pixel Depth, 0x18 => 24 Bits */ + fputc (0x20, f); /* Image Descriptor */ + fclose(f); + f = fopen( filename, "ab" ); /* reopen in binary append mode */ + for (y=height-1; y>=0; y--) { + for (x=0; x=0; y--) { + for (x=0; x=0; y--) { + for (x=0; x1) { - /* write PPM file */ - FILE *f = fopen( argv[1], "w" ); - if (f) { - int i, x, y; - GLubyte *ptr = (GLubyte *) buffer; -#define BINARY 0 -#if BINARY - fprintf(f,"P6\n"); - fprintf(f,"# ppm-file created by %s\n", argv[0]); - fprintf(f,"%i %i\n", WIDTH,HEIGHT); - fprintf(f,"255\n"); - fclose(f); - f = fopen( argv[1], "ab" ); /* reopen in binary append mode */ - for (y=HEIGHT-1; y>=0; y--) { - for (x=0; x=0; y--) { - for (x=0; x