mirror of
https://github.com/dhewm/dhewm3.git
synced 2024-11-23 04:51:56 +00:00
If creating window fails, first try to reduce MSAA level, fix #440
so if someone configured 16x AA on a system that doesn't support it (like when using AMDs open source driver), 8x will be tried before falling back to a 640x480 window with no AA at all. (and then it'll try 4x and then 2x and then no AA at all, and only then reducing color depth will start, and even later it'll fall back to a small 640x480 window)
This commit is contained in:
parent
815099f833
commit
d09ccb8539
1 changed files with 37 additions and 4 deletions
|
@ -168,6 +168,9 @@ bool GLimp_Init(glimpParms_t parms) {
|
|||
int stencilbits = 8;
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
|
||||
int multisamples = parms.multiSamples;
|
||||
|
||||
// 0 - default
|
||||
// 1 - minus colorbits
|
||||
// 2 - minus depthbits
|
||||
|
@ -226,6 +229,8 @@ bool GLimp_Init(glimpParms_t parms) {
|
|||
|
||||
int talphabits = r_waylandcompat.GetBool() ? 0 : channelcolorbits;
|
||||
|
||||
try_again:
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, channelcolorbits);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, channelcolorbits);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, channelcolorbits);
|
||||
|
@ -237,8 +242,8 @@ bool GLimp_Init(glimpParms_t parms) {
|
|||
|
||||
SDL_GL_SetAttribute(SDL_GL_STEREO, parms.stereo ? 1 : 0);
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, parms.multiSamples ? 1 : 0);
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, parms.multiSamples);
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, (multisamples > 1) ? 1 : 0);
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, multisamples);
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
|
||||
|
@ -284,9 +289,23 @@ bool GLimp_Init(glimpParms_t parms) {
|
|||
parms.width, parms.height, flags);
|
||||
|
||||
if (!window) {
|
||||
common->DPrintf("Couldn't set GL mode %d/%d/%d: %s",
|
||||
channelcolorbits, tdepthbits, tstencilbits, SDL_GetError());
|
||||
common->Warning("Couldn't set GL mode %d/%d/%d with %dx MSAA: %s",
|
||||
channelcolorbits, tdepthbits, tstencilbits, parms.multiSamples, SDL_GetError());
|
||||
|
||||
// before trying to reduce color channel size or whatever, first try reducing MSAA, if possible
|
||||
if(multisamples > 1) {
|
||||
multisamples = (multisamples <= 2) ? 0 : (multisamples/2);
|
||||
|
||||
// using goto because enhancing that logic which reduces attributes
|
||||
// based on i (so it'd first try reducing MSAA) would be too painful
|
||||
goto try_again;
|
||||
}
|
||||
|
||||
continue;
|
||||
} else {
|
||||
// creating the window succeeded, so adjust r_multiSamples to the value that was actually used
|
||||
parms.multiSamples = multisamples;
|
||||
r_multiSamples.SetInteger(multisamples);
|
||||
}
|
||||
|
||||
/* Check if we're really in the requested display mode. There is
|
||||
|
@ -380,7 +399,21 @@ bool GLimp_Init(glimpParms_t parms) {
|
|||
if (!window) {
|
||||
common->DPrintf("Couldn't set GL mode %d/%d/%d: %s",
|
||||
channelcolorbits, tdepthbits, tstencilbits, SDL_GetError());
|
||||
|
||||
// before trying to reduce color channel size or whatever, first try reducing MSAA, if possible
|
||||
if(multisamples > 1) {
|
||||
multisamples = (multisamples <= 2) ? 0 : (multisamples/2);
|
||||
|
||||
// using goto because enhancing that logic which reduces attributes
|
||||
// based on i (so it'd first try reducing MSAA) would be too painful
|
||||
goto try_again;
|
||||
}
|
||||
|
||||
continue;
|
||||
} else {
|
||||
// creating the window succeeded, so adjust r_multiSamples to the value that was actually used
|
||||
parms.multiSamples = multisamples;
|
||||
r_multiSamples.SetInteger(multisamples);
|
||||
}
|
||||
|
||||
glConfig.vidWidth = window->w;
|
||||
|
|
Loading…
Reference in a new issue