From bd13ff3040ea5d30009892eecc31854ed11ac408 Mon Sep 17 00:00:00 2001 From: "John F. Fay" Date: Sun, 23 Jan 2011 18:58:54 +0000 Subject: [PATCH] Part one of fixing bug 3058987 -- the 'freeglut_patch_visual_info.diff' changes 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 | 2 +- src/freeglut_state.c | 2 +- src/freeglut_window.c | 23 +++++++++++++++++------ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/freeglut_internal.h b/src/freeglut_internal.h index ed01830..2f3155b 100644 --- a/src/freeglut_internal.h +++ b/src/freeglut_internal.h @@ -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 */ diff --git a/src/freeglut_state.c b/src/freeglut_state.c index 589f8ff..9126c4f 100644 --- a/src/freeglut_state.c +++ b/src/freeglut_state.c @@ -320,7 +320,7 @@ int FGAPIENTRY glutGet( GLenum eWhat ) GLXFBConfig * fbconfig; int isPossible; - fbconfig = fgChooseFBConfig(); + fbconfig = fgChooseFBConfig(NULL); if (fbconfig == NULL) { diff --git a/src/freeglut_window.c b/src/freeglut_window.c index 00bdfdd..e9da324 100644 --- a/src/freeglut_window.c +++ b/src/freeglut_window.c @@ -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. -- 1.7.10.4