@@ -222,6 +222,15 @@ void *glx_init(glx_opengl_version_t version)
222222 };
223223
224224 int glx_major , glx_minor ;
225+
226+ int fbcount ;
227+ int best_fbc = -1 , worst_fbc = -1 , best_num_samp = -1 , worst_num_samp = 999 ;
228+ GLXFBConfig * fbc ;
229+ GLXFBConfig bestFbc ;
230+ XVisualInfo * vi ;
231+ const char * glxExts ;
232+ glXCreateContextAttribsARBProc glXCreateContextAttribsARB ;
233+ int (* oldHandler )(Display * , XErrorEvent * );
225234
226235 // FBConfigs were added in GLX version 1.3.
227236 if ( !glXQueryVersion ( display , & glx_major , & glx_minor ) ||
@@ -232,8 +241,7 @@ void *glx_init(glx_opengl_version_t version)
232241 }
233242
234243 printf ( "Getting matching framebuffer configs\n" );
235- int fbcount ;
236- GLXFBConfig * fbc = glXChooseFBConfig ( display , DefaultScreen ( display ),
244+ fbc = glXChooseFBConfig ( display , DefaultScreen ( display ),
237245 visual_attribs , & fbcount );
238246 if ( !fbc )
239247 {
@@ -244,10 +252,8 @@ void *glx_init(glx_opengl_version_t version)
244252
245253 // Pick the FB config/visual with the most samples per pixel
246254 printf ( "Getting XVisualInfos\n" );
247- int best_fbc = -1 , worst_fbc = -1 , best_num_samp = -1 , worst_num_samp = 999 ;
248255
249- int i ;
250- for ( i = 0 ; i < fbcount ; i ++ )
256+ for ( int i = 0 ; i < fbcount ; i ++ )
251257 {
252258 XVisualInfo * vi = glXGetVisualFromFBConfig ( display , fbc [i ] );
253259 if ( vi )
@@ -268,13 +274,13 @@ void *glx_init(glx_opengl_version_t version)
268274 XFree ( vi );
269275 }
270276
271- GLXFBConfig bestFbc = fbc [ best_fbc ];
277+ bestFbc = fbc [ best_fbc ];
272278
273279 // Be sure to free the FBConfig list allocated by glXChooseFBConfig()
274280 XFree ( fbc );
275281
276282 // Get a visual
277- XVisualInfo * vi = glXGetVisualFromFBConfig ( display , bestFbc );
283+ vi = glXGetVisualFromFBConfig ( display , bestFbc );
278284 printf ( "Chosen visual ID = 0x%x\n" , (unsigned int ) vi -> visualid );
279285
280286 printf ( "Creating colormap\n" );
@@ -309,12 +315,12 @@ void *glx_init(glx_opengl_version_t version)
309315 XMapWindow( display, win );*/
310316
311317 // Get the default screen's GLX extension list
312- const char * glxExts = glXQueryExtensionsString ( display ,
318+ glxExts = glXQueryExtensionsString ( display ,
313319 DefaultScreen ( display ) );
314320
315321 // NOTE: It is not necessary to create or make current to a context before
316322 // calling glXGetProcAddressARB
317- glXCreateContextAttribsARBProc glXCreateContextAttribsARB = 0 ;
323+ glXCreateContextAttribsARB = 0 ;
318324 glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc )
319325 glXGetProcAddressARB ( (const GLubyte * ) "glXCreateContextAttribsARB" );
320326
@@ -327,8 +333,7 @@ void *glx_init(glx_opengl_version_t version)
327333 // of a process use the same error handler, so be sure to guard against other
328334 // threads issuing X commands while this code is running.
329335 ctxErrorOccurred = FALSE;
330- int (* oldHandler )(Display * , XErrorEvent * ) =
331- XSetErrorHandler (& ctxErrorHandler );
336+ oldHandler = XSetErrorHandler (& ctxErrorHandler );
332337
333338 // Check for the GLX_ARB_create_context extension string and the function.
334339 // If either is not present, use GLX 1.3 context creation method.
0 commit comments