]> 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 4be5096068fdbb202c8b00064491ca8c77233dfd..e986d61b9aee4b513216d54f7824a5a728044e9d 100644 (file)
@@ -2,19 +2,20 @@
 //
 // Contributed by Richard Kaszeta <bofh@me.umn.edu>, started October 1999.
 //
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
 //
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// General Public License for more details.
+// Library General Public License for more details.
 //
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the
+// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA  02111-1307, USA.
 //
 // $Id$
 
@@ -32,7 +33,7 @@
 #include <limits.h>
 
 #include <GL/glut.h>
-#include <simgear/xgl.h>
+#include <simgear/xgl/xgl.h>
 
 #include "screen-dump.hxx"
 
@@ -49,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;