]> git.mxchange.org Git - simgear.git/blobdiff - simgear/screen/screen-dump.cxx
Add a bunch of extensions in preparation of render-to-texture support.
[simgear.git] / simgear / screen / screen-dump.cxx
index ebde34ca362b46d9932efbc96387c1dedcbc2f3c..ce4b5c45ff1e5bcb9fa8718382c1a6ba9144b80c 100644 (file)
 
 
 #ifdef HAVE_CONFIG_H
-#  include <config.h>
+#  include <simgear_config.h>
 #endif
 
-#ifdef HAVE_WINDOWS_H
-#  include <windows.h>                     
+#if defined(__CYGWIN__)  /* && !defined(USING_X) */
+#define WIN32
+#endif
+
+#if defined(WIN32)  /* MINGW and MSC predefine WIN32 */
+# include <windows.h>
 #endif
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <limits.h>
 
-#include <GL/glut.h>
-#include <simgear/xgl/xgl.h>
+#include <simgear/compiler.h>
+
+#include SG_GL_H
 
 #include "screen-dump.hxx"
 
@@ -41,7 +46,7 @@
 #define RGB3 3                 // 3 bytes of color info per pixel
 #define RGBA 4                 // 4 bytes of color+alpha info
 
-void my_glWritePPMFile(const char *filename, GLubyte *buffer, int win_width, int win_height, int mode)
+bool sg_glWritePPMFile(const char *filename, GLubyte *buffer, int win_width, int win_height, int mode)
 {
     int i, j, k, q;
     unsigned char *ibuffer;
@@ -52,7 +57,7 @@ void my_glWritePPMFile(const char *filename, GLubyte *buffer, int win_width, int
 
     if ( (fp = fopen(filename, "wb")) == NULL ) {
        printf("Warning: cannot open %s\n", filename);
-       return;
+       return false;
     }
 
     fprintf(fp, "P6\n# CREATOR: glReadPixel()\n%d %d\n%d\n",
@@ -69,12 +74,14 @@ void my_glWritePPMFile(const char *filename, GLubyte *buffer, int win_width, int
 
     printf("wrote file (%d x %d pixels, %d bytes)\n",
           win_width, win_height, RGB3*win_width*win_height);
+    return true;
 }
 
 
 // dump the screen buffer to a ppm file
-void my_glDumpWindow(const char *filename, int win_width, int win_height) {
+bool sg_glDumpWindow(const char *filename, int win_width, int win_height) {
     GLubyte *buffer;
+    bool result;
 
     buffer = (GLubyte *) malloc(win_width*win_height*RGBA);
 
@@ -82,7 +89,10 @@ void my_glDumpWindow(const char *filename, int win_width, int win_height) {
     glFinish();
     glReadPixels(0, 0, win_width, win_height, 
                 GL_RGBA, GL_UNSIGNED_BYTE, buffer);
-       my_glWritePPMFile( filename, buffer, win_width, win_height, GL_RGBA );
+    result = sg_glWritePPMFile( filename, buffer, win_width, win_height,
+                               GL_RGBA );
     free(buffer);
+
+    return result;
 }