Part one of fixing bug 3058987 -- the 'freeglut_patch_visual_info.diff' changes
authorJohn F. Fay <johnffay@nettally.com>
Sun, 23 Jan 2011 18:58:54 +0000 (18:58 +0000)
committerJohn F. Fay <johnffay@nettally.com>
Sun, 23 Jan 2011 18:58:54 +0000 (18:58 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@884 7f0cb862-5218-0410-a997-914c9d46530a

src/freeglut_internal.h
src/freeglut_state.c
src/freeglut_window.c

index ed01830..2f3155b 100644 (file)
@@ -825,7 +825,7 @@ void fgDestroyStructure( void );
 
 /* A helper function to check if a display mode is possible to use */
 #if TARGET_HOST_POSIX_X11
-GLXFBConfig* fgChooseFBConfig( void );
+GLXFBConfig* fgChooseFBConfig( int* numcfgs );
 #endif
 
 /* The window procedure for Win32 events handling */
index 589f8ff..9126c4f 100644 (file)
@@ -320,7 +320,7 @@ int FGAPIENTRY glutGet( GLenum eWhat )
         GLXFBConfig * fbconfig;
         int isPossible;
 
-        fbconfig = fgChooseFBConfig();
+        fbconfig = fgChooseFBConfig(NULL);
 
         if (fbconfig == NULL)
         {
index 00bdfdd..e9da324 100644 (file)
@@ -220,7 +220,7 @@ static void fghContextCreationError( void )
  * Chooses a visual basing on the current display mode settings
  */
 
-GLXFBConfig* fgChooseFBConfig( void )
+GLXFBConfig* fgChooseFBConfig( int *numcfgs )
 {
   GLboolean wantIndexedMode = GL_FALSE;
   int attributes[ 100 ];
@@ -385,6 +385,9 @@ GLXFBConfig* fgChooseFBConfig( void )
            fbconfig = NULL;
         }
 
+       if (numcfgs)
+               *numcfgs = fbconfigArraySize;
+
         return fbconfig;
     }
 }
@@ -904,13 +907,14 @@ void fgOpenWindow( SFG_Window* window, const char* title,
     XSizeHints sizeHints;
     XWMHints wmHints;
     unsigned long mask;
+    int num_FBConfigs, i;
     unsigned int current_DisplayMode = fgState.DisplayMode ;
 
     /* Save the display mode if we are creating a menu window */
     if( window->IsMenu && ( ! fgStructure.MenuContext ) )
         fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB ;
 
-    window->Window.FBConfig = fgChooseFBConfig( );
+    window->Window.FBConfig = fgChooseFBConfig( &num_FBConfigs );
 
     if( window->IsMenu && ( ! fgStructure.MenuContext ) )
         fgState.DisplayMode = current_DisplayMode ;
@@ -925,14 +929,14 @@ void fgOpenWindow( SFG_Window* window, const char* title,
         if( !( fgState.DisplayMode & GLUT_DOUBLE ) )
         {
             fgState.DisplayMode |= GLUT_DOUBLE ;
-            window->Window.FBConfig = fgChooseFBConfig( );
+            window->Window.FBConfig = fgChooseFBConfig( &num_FBConfigs );
             fgState.DisplayMode &= ~GLUT_DOUBLE;
         }
 
         if( fgState.DisplayMode & GLUT_MULTISAMPLE )
         {
             fgState.DisplayMode &= ~GLUT_MULTISAMPLE ;
-            window->Window.FBConfig = fgChooseFBConfig( );
+            window->Window.FBConfig = fgChooseFBConfig( &num_FBConfigs );
             fgState.DisplayMode |= GLUT_MULTISAMPLE;
         }
     }
@@ -941,8 +945,15 @@ void fgOpenWindow( SFG_Window* window, const char* title,
                                   "FBConfig with necessary capabilities not found", "fgOpenWindow" );
 
     /*  Get the X visual.  */
-    visualInfo = glXGetVisualFromFBConfig( fgDisplay.Display,
-                                           *(window->Window.FBConfig) );
+    for (i = 0; i < num_FBConfigs; i++) {
+           visualInfo = glXGetVisualFromFBConfig( fgDisplay.Display,
+                                                  window->Window.FBConfig[i] );
+           if (visualInfo)
+               break;
+    }
+
+    FREEGLUT_INTERNAL_ERROR_EXIT( visualInfo != NULL,
+                                  "visualInfo could not be retrieved from FBConfig", "fgOpenWindow" );
 
     /*
      * XXX HINT: the masks should be updated when adding/removing callbacks.