X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=freeglut-1.3%2Ffreeglut_window.c;h=7bd5700ff3283e4a4d7b5a9905138925cc986ba3;hb=9d66916bab11e22ff2b670638be3a50e604897a1;hp=6553477c2a824b34226569acf84e5ef55fb3630b;hpb=9777fcaf88f0f791fdd6b78f86fde4ac066d1c1e;p=freeglut diff --git a/freeglut-1.3/freeglut_window.c b/freeglut-1.3/freeglut_window.c index 6553477..7bd5700 100644 --- a/freeglut-1.3/freeglut_window.c +++ b/freeglut-1.3/freeglut_window.c @@ -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 );