Added FREEGLUT_VERSION_1_3.
[freeglut] / freeglut-1.3 / freeglut_window.c
index 6553477..7bd5700 100644 (file)
@@ -364,6 +364,27 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i
      * Here we are upon the stage. Have the visual selected.
      */
     window->Window.VisualInfo = fgChooseVisual();
+    if ( ! window->Window.VisualInfo )
+    {
+      /*
+       * The "fgChooseVisual" returned a null meaning that the visual context is not available.
+       * Try a couple of variations to see if they will work.
+       */
+      if ( ! ( fgState.DisplayMode & GLUT_DOUBLE ) )
+      {
+        /*
+         * Single buffering--try it doubled
+         */
+        fgState.DisplayMode |= GLUT_DOUBLE ;
+        window->Window.VisualInfo = fgChooseVisual();
+      }
+
+      /*
+       * GLUT also checks for multi-sampling, but I don't see that anywhere else in FREEGLUT
+       * so I won't bother with it for the moment.
+       */
+    }
+
     assert( window->Window.VisualInfo != NULL );
 
     /*
@@ -602,6 +623,20 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i
 #endif
 
     /*
+     * Save the window's single- or double-buffering state
+     */
+    window->Window.DoubleBuffered = ( fgState.DisplayMode & GLUT_DOUBLE ) ? 1 : 0 ;
+
+    /*
+     * If it's not double-buffered, make sure the rendering is done to the front buffer.
+     */
+    if ( ! window->Window.DoubleBuffered )
+    {
+      glDrawBuffer ( GL_FRONT ) ;
+      glReadBuffer ( GL_FRONT ) ;
+    }
+
+    /*
      * Set the newly created window as the current one
      */
     fgSetWindow( window );