[Plib-cvs] plib/src/ssgAux ssgaScreenDump.cxx,1.2,1.3 ssgaScreenDump.h,1.1,1.2
Brought to you by:
sjbaker
From: Steve B. <sj...@us...> - 2004-02-16 02:34:16
|
Update of /cvsroot/plib/plib/src/ssgAux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20530/plib/src/ssgAux Modified Files: ssgaScreenDump.cxx ssgaScreenDump.h Log Message: Added the 'PW' library. Added some functionality to the ssgAux screen dump facility so you can dump to an array in memory as an alternative to dumping it straight to disk. Index: ssgaScreenDump.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/ssgAux/ssgaScreenDump.cxx,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ssgaScreenDump.cxx 4 Jul 2003 13:50:56 -0000 1.2 +++ ssgaScreenDump.cxx 16 Feb 2004 02:26:28 -0000 1.3 @@ -48,7 +48,7 @@ } -void ssgaScreenDump ( char *filename, int xsize, int ysize ) +void ssgaScreenDump ( char *filename, int xsize, int ysize, int frontBuffer ) { FILE *fd = fopen ( filename, "wb" ) ; @@ -59,13 +59,8 @@ return ; } - unsigned char *buffer = new unsigned char [ xsize * ysize * 3 ] ; unsigned char *row = new unsigned char [ xsize ] ; - - glReadBuffer ( GL_FRONT ) ; - glReadPixels( 0, 0, xsize, ysize, GL_RGB, GL_UNSIGNED_BYTE, - (void *) buffer ) ; - glReadBuffer ( GL_BACK ) ; + unsigned char *buffer = ssgaScreenDump ( xsize, ysize, frontBuffer ) ; char type = 0 /* RGB_IMG_VERBATIM */ ; short dim = 3 ; @@ -113,3 +108,19 @@ } +unsigned char *ssgaScreenDump ( int xsize, int ysize, int frontBuffer ) +{ + unsigned char *buffer = new unsigned char [ xsize * ysize * 3 ] ; + + if ( frontBuffer ) + glReadBuffer ( GL_FRONT ) ; + + glReadPixels( 0, 0, xsize, ysize, GL_RGB, GL_UNSIGNED_BYTE, + (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.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ssgaScreenDump.h 27 Jun 2003 08:15:15 -0000 1.1 +++ ssgaScreenDump.h 16 Feb 2004 02:26:28 -0000 1.2 @@ -1,3 +1,14 @@ -void ssgaScreenDump ( char *filename, int width, int height ) ; +/* Dump to disk in '.rgb' format */ + +void ssgaScreenDump ( 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 ) ; + + |