X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=freeglut-1.3%2Ffreeglut_window.c;fp=freeglut-1.3%2Ffreeglut_window.c;h=7d67b61939ca103c4b1c82e56922b0b778cadff0;hb=583baa8756a71ed088b8e46c52a945218037314c;hp=6553477c2a824b34226569acf84e5ef55fb3630b;hpb=c95c14914f3522c023ff9439fc7be0656002df19;p=freeglut diff --git a/freeglut-1.3/freeglut_window.c b/freeglut-1.3/freeglut_window.c index 6553477..7d67b61 100644 --- a/freeglut-1.3/freeglut_window.c +++ b/freeglut-1.3/freeglut_window.c @@ -361,9 +361,35 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i freeglut_assert_ready; /* + * Save the window's single- or double-buffering state + */ + window->Window.DoubleBuffered = ( fgState.DisplayMode & GLUT_DOUBLE ) ? 1 : 0 ; + + /* * 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 ); /* @@ -515,6 +541,15 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i # endif } + /* + * 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 ) ; + } + #elif TARGET_HOST_WIN32 WNDCLASS wc;