]> git.mxchange.org Git - simgear.git/blobdiff - XGL/xgl.c
FreeBSD support.
[simgear.git] / XGL / xgl.c
index 103bd57ce8ae74d91ebbf27b26d96fdda9b55308..653805240e350521569408ddc8b60d5f0e814469 100644 (file)
--- a/XGL/xgl.c
+++ b/XGL/xgl.c
@@ -1,15 +1,22 @@
-#include <stdio.h>
-#include <stdlib.h>
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
 
-#ifdef WIN32
+#ifdef HAVE_WINDOWS_H
 #  include <windows.h>
-#else
-#  include <unistd.h>
 #endif
 
 #include "xgl.h"
 #include <GL/glut.h>
 
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef HAVE_UNISTD_H
+#  include <unistd.h>
+#endif
+
+
 #ifdef XGL_TRACE
 
 #ifndef TRUE
@@ -2772,8 +2779,13 @@ void xglutIdleFunc ( void (*func)(void) )
 
 void xglutInit ( int* argcp, char** argv )
 {
+  if(!xglTraceFd ) {     // Not defined by any other means, must be here
+    xglTraceFd = stdout; // avoid a crash from a NULL ptr.
+    }
   if ( xglTraceIsEnabled("glutInit") )
-    fprintf ( xglTraceFd, "  /* glutInit ( (int *)0x%08x, (char **)0x%08x ) ; */\n" , argcp, argv ) ;
+    fprintf ( xglTraceFd,
+              "  /* glutInit ( (int *)0x%08x, (char **)0x%08x ) ; */\n" ,
+              argcp, argv ) ;
   if ( xglExecuteIsEnabled("glutInit") )
     glutInit ( argcp, argv ) ;
 }