]> git.mxchange.org Git - simgear.git/commitdiff
Added a touch of error checking to the screen dump routine, i.e. don't
authorcurt <curt>
Sat, 9 Sep 2000 13:31:45 +0000 (13:31 +0000)
committercurt <curt>
Sat, 9 Sep 2000 13:31:45 +0000 (13:31 +0000)
die if you can't open the output file.

simgear/screen/screen-dump.cxx

index da4eabb4f4aa0c6d123ad6eebd58dc7d9629d586..e986d61b9aee4b513216d54f7824a5a728044e9d 100644 (file)
@@ -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;