comparison src/video/windib/SDL_dibvideo.c @ 1295:c3e36ac8a94c

Date: Sun, 6 Mar 2005 17:06:20 +0100 From: Per Inge Mathisen Subject: [SDL] Fullscreen refresh on win32 Windows has a terrible default for fullscreen 3D apps of 60mhz refresh rate. This can be fixed by the user by going into his driver's control panel and forcing the refresh rate higher. However, this not a very user friendly way about it, and in any case SDL contains no code that could figure out this that condition has afflicted the user. So the question is, could SDL fix this for the user? It is possible under Windows to request a higher refresh rate. The danger is of course that if the user has an old monitor, and you request a too high refresh rate, the monitor could be damaged. However, I believe there might be a way around that: Check before switching what refresh rate the user's desktop runs in, and if our fullscreen dimensions are equal or less than those of the desktop, use the higher refresh rate of 60 and the desktop rate. Since most users run their desktops in the same or higher resolution something sane, this should fix this problem for most users. Thoughts? An alternative is to add an SDL_GL_GetAttribute(SDL_GL_REFRESH_RATE) option so that programs can bitch at their users at their own convenience. - Per
author Sam Lantinga <slouken@libsdl.org>
date Mon, 30 Jan 2006 06:56:10 +0000
parents 59c7a470a51e
children c9b51268668f
comparison
equal deleted inserted replaced
1294:1760ceb23bc6 1295:c3e36ac8a94c
333 333
334 /* See if gamma is supported on this screen */ 334 /* See if gamma is supported on this screen */
335 DIB_CheckGamma(this); 335 DIB_CheckGamma(this);
336 336
337 #ifndef NO_CHANGEDISPLAYSETTINGS 337 #ifndef NO_CHANGEDISPLAYSETTINGS
338 /* Query for the desktop resolution */
339 EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode);
340
338 /* Query for the list of available video modes */ 341 /* Query for the list of available video modes */
339 for ( i=0; EnumDisplaySettings(NULL, i, &settings); ++i ) { 342 for ( i=0; EnumDisplaySettings(NULL, i, &settings); ++i ) {
340 DIB_AddMode(this, settings.dmBitsPerPel, 343 DIB_AddMode(this, settings.dmBitsPerPel,
341 settings.dmPelsWidth, settings.dmPelsHeight); 344 settings.dmPelsWidth, settings.dmPelsHeight);
342 } 345 }
531 534
532 #ifndef NO_CHANGEDISPLAYSETTINGS 535 #ifndef NO_CHANGEDISPLAYSETTINGS
533 /* Set fullscreen mode if appropriate */ 536 /* Set fullscreen mode if appropriate */
534 if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { 537 if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
535 DEVMODE settings; 538 DEVMODE settings;
539 BOOL changed;
536 540
537 memset(&settings, 0, sizeof(DEVMODE)); 541 memset(&settings, 0, sizeof(DEVMODE));
538 settings.dmSize = sizeof(DEVMODE); 542 settings.dmSize = sizeof(DEVMODE);
539 settings.dmBitsPerPel = video->format->BitsPerPixel; 543 settings.dmBitsPerPel = video->format->BitsPerPixel;
540 settings.dmPelsWidth = width; 544 settings.dmPelsWidth = width;
541 settings.dmPelsHeight = height; 545 settings.dmPelsHeight = height;
542 settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL; 546 settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
543 if ( ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL ) { 547 if ( width <= SDL_desktop_mode.dmPelsWidth && height <= SDL_desktop_mode.dmPelsHeight ) {
548 settings.dmDisplayFrequency = SDL_desktop_mode.dmDisplayFrequency;
549 settings.dmFields |= DM_DISPLAYFREQUENCY;
550 }
551 changed = (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL);
552 if ( ! changed && (settings.dmFields & DM_DISPLAYFREQUENCY) ) {
553 settings.dmFields &= ~DM_DISPLAYFREQUENCY;
554 changed = (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL);
555 }
556 if ( changed ) {
544 video->flags |= SDL_FULLSCREEN; 557 video->flags |= SDL_FULLSCREEN;
545 SDL_fullscreen_mode = settings; 558 SDL_fullscreen_mode = settings;
546 } 559 }
547 } 560 }
548 #endif /* !NO_CHANGEDISPLAYSETTINGS */ 561 #endif /* !NO_CHANGEDISPLAYSETTINGS */