From: curt Date: Sat, 9 Sep 2000 13:31:45 +0000 (+0000) Subject: Added a touch of error checking to the screen dump routine, i.e. don't X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b0134a377ec703e82ed5e3f9dd18882122c1a11a;p=simgear.git Added a touch of error checking to the screen dump routine, i.e. don't die if you can't open the output file. --- diff --git a/simgear/screen/screen-dump.cxx b/simgear/screen/screen-dump.cxx index da4eabb4..e986d61b 100644 --- a/simgear/screen/screen-dump.cxx +++ b/simgear/screen/screen-dump.cxx @@ -50,7 +50,11 @@ void my_glWritePPMFile(const char *filename, GLubyte *buffer, int win_width, int ibuffer = (unsigned char *) malloc(win_width*win_height*RGB); - fp = fopen(filename, "wb"); + if ( (fp = fopen(filename, "wb")) == NULL ) { + printf("Warning: cannot open %s\n", filename); + return; + } + fprintf(fp, "P6\n# CREATOR: glReadPixel()\n%d %d\n%d\n", win_width, win_height, UCHAR_MAX); q = 0;