From: curt Date: Sun, 22 Apr 2001 20:02:49 +0000 (+0000) Subject: Screen shot tweaks from Cameron Moore. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ebdb86c46074ef1786b09a028f4cb4b36a7edb8f;p=simgear.git Screen shot tweaks from Cameron Moore. --- diff --git a/simgear/screen/screen-dump.cxx b/simgear/screen/screen-dump.cxx index ebde34ca..8a9da20f 100644 --- a/simgear/screen/screen-dump.cxx +++ b/simgear/screen/screen-dump.cxx @@ -41,7 +41,7 @@ #define RGB3 3 // 3 bytes of color info per pixel #define RGBA 4 // 4 bytes of color+alpha info -void my_glWritePPMFile(const char *filename, GLubyte *buffer, int win_width, int win_height, int mode) +bool sg_glWritePPMFile(const char *filename, GLubyte *buffer, int win_width, int win_height, int mode) { int i, j, k, q; unsigned char *ibuffer; @@ -52,7 +52,7 @@ void my_glWritePPMFile(const char *filename, GLubyte *buffer, int win_width, int if ( (fp = fopen(filename, "wb")) == NULL ) { printf("Warning: cannot open %s\n", filename); - return; + return false; } fprintf(fp, "P6\n# CREATOR: glReadPixel()\n%d %d\n%d\n", @@ -69,12 +69,14 @@ void my_glWritePPMFile(const char *filename, GLubyte *buffer, int win_width, int printf("wrote file (%d x %d pixels, %d bytes)\n", win_width, win_height, RGB3*win_width*win_height); + return true; } // dump the screen buffer to a ppm file -void my_glDumpWindow(const char *filename, int win_width, int win_height) { +bool sg_glDumpWindow(const char *filename, int win_width, int win_height) { GLubyte *buffer; + bool result; buffer = (GLubyte *) malloc(win_width*win_height*RGBA); @@ -82,7 +84,10 @@ void my_glDumpWindow(const char *filename, int win_width, int win_height) { glFinish(); glReadPixels(0, 0, win_width, win_height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - my_glWritePPMFile( filename, buffer, win_width, win_height, GL_RGBA ); + result = sg_glWritePPMFile( filename, buffer, win_width, win_height, + GL_RGBA ); free(buffer); + + return result; } diff --git a/simgear/screen/screen-dump.hxx b/simgear/screen/screen-dump.hxx index 41da1b05..49809af5 100644 --- a/simgear/screen/screen-dump.hxx +++ b/simgear/screen/screen-dump.hxx @@ -29,7 +29,7 @@ * @param win_width width of our opengl window * @param win_height height of our opengl window */ -void my_glDumpWindow( const char *filename, int win_width, int win_height ); +bool sg_glDumpWindow( const char *filename, int win_width, int win_height ); /** @@ -40,5 +40,5 @@ void my_glDumpWindow( const char *filename, int win_width, int win_height ); * @param win_height height of buffer * @param mode one of GL_RGBA, GL_RGB, etc. */ -void my_glWritePPMFile( const char *filename, GLubyte *buffer, int win_width, +bool sg_glWritePPMFile( const char *filename, GLubyte *buffer, int win_width, int win_height, int mode);