[Plib-cvs] plib/src/ssgAux ssgaFire.cxx,1.5,1.6 ssgaScreenDump.cxx,1.3,1.4 ssgaScreenDump.h,1.2,1.3
Brought to you by:
sjbaker
From: Steve B. <sj...@us...> - 2004-12-29 07:19:56
|
Update of /cvsroot/plib/plib/src/ssgAux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10737/plib/src/ssgAux Modified Files: ssgaFire.cxx ssgaScreenDump.cxx ssgaScreenDump.h Log Message: Fixed some bugs in tweening. Added functions to dump Z buffer into ssgaScreenDump. Index: ssgaFire.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/ssgAux/ssgaFire.cxx,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- ssgaFire.cxx 2 Sep 2002 06:05:49 -0000 1.5 +++ ssgaFire.cxx 29 Dec 2004 07:19:40 -0000 1.6 @@ -126,6 +126,7 @@ static int preFireDraw ( ssgEntity * ) { + glDisable ( GL_FOG ) ; glBlendFunc ( GL_ONE, GL_ONE ) ; return TRUE ; } @@ -134,6 +135,7 @@ static int postFireDraw ( ssgEntity * ) { glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ; + glEnable ( GL_FOG ) ; return TRUE ; } Index: ssgaScreenDump.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/ssgAux/ssgaScreenDump.cxx,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ssgaScreenDump.cxx 16 Feb 2004 02:26:28 -0000 1.3 +++ ssgaScreenDump.cxx 29 Dec 2004 07:19:40 -0000 1.4 @@ -48,6 +48,67 @@ } +void ssgaScreenDepthDump ( char *filename, + int xsize, int ysize, int frontBuffer ) +{ + FILE *fd = fopen ( filename, "wb" ) ; + + if ( fd == NULL ) + { + fprintf ( stderr, "Failed to open '%s' for writing screendepthdump.\n", + filename ) ; + return ; + } + + unsigned char *row = new unsigned char [ xsize ] ; + unsigned int *buffer = ssgaScreenDepthDump ( xsize, ysize, frontBuffer ) ; + + char type = 0 /* RGB_IMG_VERBATIM */ ; + short dim = 3 ; + short zsize = 3 ; + char bpp = 1 ; + int min = 0 ; + int max = 255 ; + short magic = 0x01DA /* RGB_IMG_MAGIC */ ; + int colormap = 0 ; + int i ; + + writeShort ( fd, magic ) ; + writeByte ( fd, type ) ; + writeByte ( fd, bpp ) ; + writeShort ( fd, dim ) ; + writeShort ( fd, xsize ) ; + writeShort ( fd, ysize ) ; + writeShort ( fd, zsize ) ; + writeInt ( fd, min ) ; + writeInt ( fd, max ) ; + writeInt ( fd, 0 ) ; /* Dummy field */ + + for ( i = 0 ; i < 80 ; i++ ) + writeByte ( fd, '\0' ) ; /* Name field */ + + writeInt ( fd, colormap ) ; + + for ( i = 0 ; i < 404 ; i++ ) + writeByte ( fd, 0 ) ; /* Dummy field */ + + for ( int z = 0 ; z < 3 ; z++ ) + for ( int y = 0 ; y < ysize ; y++ ) + { + for ( i = 0 ; i < xsize ; i++ ) + row [ i ] = ((buffer [ y * xsize + i ] >> (8*z)) & 0xFF) ; + + fseek ( fd, ( z * ysize + y ) * xsize + 512, SEEK_SET ) ; + fwrite ( row, 1, xsize, fd ) ; + } + + fclose ( fd ) ; + + delete row ; + delete buffer ; +} + + void ssgaScreenDump ( char *filename, int xsize, int ysize, int frontBuffer ) { FILE *fd = fopen ( filename, "wb" ) ; @@ -124,3 +185,20 @@ } + +unsigned int *ssgaScreenDepthDump ( int xsize, int ysize, int frontBuffer ) +{ + unsigned int *buffer = new unsigned int [ xsize * ysize ] ; + + if ( frontBuffer ) + glReadBuffer ( GL_FRONT ) ; + + glReadPixels( 0, 0, xsize, ysize, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, + (void *) buffer ) ; + if ( frontBuffer ) + glReadBuffer ( GL_BACK ) ; + + return buffer ; +} + + Index: ssgaScreenDump.h =================================================================== RCS file: /cvsroot/plib/plib/src/ssgAux/ssgaScreenDump.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ssgaScreenDump.h 16 Feb 2004 02:26:28 -0000 1.2 +++ ssgaScreenDump.h 29 Dec 2004 07:19:40 -0000 1.3 @@ -5,10 +5,17 @@ int width, int height, int frontBuffer = TRUE ) ; +/* Put low order 24 bits to disk (R=lsb, G=middle byte, B=msb) */ + +void ssgaScreenDepthDump ( char *filename, + int width, int height, + int frontBuffer = TRUE ) ; + /* Dump to a memory buffer - three bytes per pixel */ unsigned char *ssgaScreenDump ( int width, int height, int frontBuffer = TRUE ) ; - +unsigned int *ssgaScreenDepthDump ( int width, int height, + int frontBuffer = TRUE ) ; |