From b0134a377ec703e82ed5e3f9dd18882122c1a11a Mon Sep 17 00:00:00 2001 From: curt Date: Sat, 9 Sep 2000 13:31:45 +0000 Subject: [PATCH] Added a touch of error checking to the screen dump routine, i.e. don't die if you can't open the output file. --- simgear/screen/screen-dump.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; -- 2.39.5