]> git.mxchange.org Git - simgear.git/blobdiff - simgear/screen/screen-dump.cxx
Added a touch of error checking to the screen dump routine, i.e. don't
[simgear.git] / 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;