comparison src/video/x11/SDL_x11gl.c @ 4290:485868a1c283 SDL-1.2

Cache the swap control setting, even on Mesa.
author Ryan C. Gordon <icculus@icculus.org>
date Sat, 10 Oct 2009 06:38:02 +0000
parents 91c458013850
children f2f8525e60c2
comparison
equal deleted inserted replaced
4289:91c458013850 4290:485868a1c283
281 if ( !glXExtensionSupported(this, "GLX_SGI_swap_control") ) { 281 if ( !glXExtensionSupported(this, "GLX_SGI_swap_control") ) {
282 this->gl_data->glXSwapIntervalSGI = NULL; 282 this->gl_data->glXSwapIntervalSGI = NULL;
283 } 283 }
284 if ( !glXExtensionSupported(this, "GLX_MESA_swap_control") ) { 284 if ( !glXExtensionSupported(this, "GLX_MESA_swap_control") ) {
285 this->gl_data->glXSwapIntervalMESA = NULL; 285 this->gl_data->glXSwapIntervalMESA = NULL;
286 this->gl_data->glXGetSwapIntervalMESA = NULL;
287 } 286 }
288 if ( this->gl_config.swap_control >= 0 ) { 287 if ( this->gl_config.swap_control >= 0 ) {
288 int rc = -1;
289 if ( this->gl_data->glXSwapIntervalMESA ) { 289 if ( this->gl_data->glXSwapIntervalMESA ) {
290 this->gl_data->glXSwapIntervalMESA(this->gl_config.swap_control); 290 rc = this->gl_data->glXSwapIntervalMESA(this->gl_config.swap_control);
291 } else if ( this->gl_data->glXSwapIntervalSGI ) { 291 } else if ( this->gl_data->glXSwapIntervalSGI ) {
292 if (this->gl_data->glXSwapIntervalSGI(this->gl_config.swap_control) == 0) { 292 rc = this->gl_data->glXSwapIntervalSGI(this->gl_config.swap_control);
293 this->gl_data->sgi_swap_interval = this->gl_config.swap_control; 293 }
294 } 294 if (rc == 0) {
295 this->gl_data->swap_interval = this->gl_config.swap_control;
295 } 296 }
296 } 297 }
297 #else 298 #else
298 SDL_SetError("X11 driver not configured with OpenGL"); 299 SDL_SetError("X11 driver not configured with OpenGL");
299 #endif 300 #endif
410 } else { 411 } else {
411 unsupported = 1; 412 unsupported = 1;
412 } 413 }
413 break; 414 break;
414 case SDL_GL_SWAP_CONTROL: 415 case SDL_GL_SWAP_CONTROL:
415 if ( this->gl_data->glXGetSwapIntervalMESA ) { 416 if ( ( this->gl_data->glXSwapIntervalMESA ) ||
416 *value = this->gl_data->glXGetSwapIntervalMESA(); 417 ( this->gl_data->glXSwapIntervalSGI ) ) {
417 return 0; 418 *value = this->gl_data->swap_interval;
418 } else if ( this->gl_data->glXSwapIntervalSGI ) {
419 *value = this->gl_data->sgi_swap_interval;
420 return 0; 419 return 0;
421 } else { 420 } else {
422 unsupported = 1; 421 unsupported = 1;
423 } 422 }
424 break; 423 break;
467 this->gl_data->glXDestroyContext = NULL; 466 this->gl_data->glXDestroyContext = NULL;
468 this->gl_data->glXMakeCurrent = NULL; 467 this->gl_data->glXMakeCurrent = NULL;
469 this->gl_data->glXSwapBuffers = NULL; 468 this->gl_data->glXSwapBuffers = NULL;
470 this->gl_data->glXSwapIntervalSGI = NULL; 469 this->gl_data->glXSwapIntervalSGI = NULL;
471 this->gl_data->glXSwapIntervalMESA = NULL; 470 this->gl_data->glXSwapIntervalMESA = NULL;
472 this->gl_data->glXGetSwapIntervalMESA = NULL;
473 471
474 this->gl_config.dll_handle = NULL; 472 this->gl_config.dll_handle = NULL;
475 this->gl_config.driver_loaded = 0; 473 this->gl_config.driver_loaded = 0;
476 } 474 }
477 #endif 475 #endif
528 (const char *(*)(Display *, int)) GL_LoadFunction(handle, "glXQueryExtensionsString"); 526 (const char *(*)(Display *, int)) GL_LoadFunction(handle, "glXQueryExtensionsString");
529 this->gl_data->glXSwapIntervalSGI = 527 this->gl_data->glXSwapIntervalSGI =
530 (int (*)(int)) GL_LoadFunction(handle, "glXSwapIntervalSGI"); 528 (int (*)(int)) GL_LoadFunction(handle, "glXSwapIntervalSGI");
531 this->gl_data->glXSwapIntervalMESA = 529 this->gl_data->glXSwapIntervalMESA =
532 (GLint (*)(unsigned)) GL_LoadFunction(handle, "glXSwapIntervalMESA"); 530 (GLint (*)(unsigned)) GL_LoadFunction(handle, "glXSwapIntervalMESA");
533 this->gl_data->glXGetSwapIntervalMESA =
534 (GLint (*)(void)) GL_LoadFunction(handle, "glXGetSwapIntervalMESA");
535 531
536 if ( (this->gl_data->glXChooseVisual == NULL) || 532 if ( (this->gl_data->glXChooseVisual == NULL) ||
537 (this->gl_data->glXCreateContext == NULL) || 533 (this->gl_data->glXCreateContext == NULL) ||
538 (this->gl_data->glXDestroyContext == NULL) || 534 (this->gl_data->glXDestroyContext == NULL) ||
539 (this->gl_data->glXMakeCurrent == NULL) || 535 (this->gl_data->glXMakeCurrent == NULL) ||