diff --git a/polymer/build/src/engine.c b/polymer/build/src/engine.c index a82c6a945..95b18ab81 100644 --- a/polymer/build/src/engine.c +++ b/polymer/build/src/engine.c @@ -7781,6 +7781,11 @@ int setgamemode(char davidoption, int daxdim, int daydim, int dabpp) { int i, j; +#if defined(USE_OPENGL) && defined(POLYMOST) + extern char nogl; + + if (nogl) dabpp = 8; +#endif if ((qsetmode == 200) && (videomodereset == 0) && (davidoption == fullscreen) && (xdim == daxdim) && (ydim == daydim) && (bpp == dabpp)) return(0); @@ -7792,6 +7797,7 @@ int setgamemode(char davidoption, int daxdim, int daydim, int dabpp) //if (checkvideomode(&daxdim, &daydim, dabpp, davidoption)<0) return (-1); //bytesperline is set in this function + j = bpp; if (setvideomode(daxdim,daydim,dabpp,davidoption) < 0) return(-1); diff --git a/polymer/build/src/sdlayer.c b/polymer/build/src/sdlayer.c index 62470bdf8..ac75eec24 100644 --- a/polymer/build/src/sdlayer.c +++ b/polymer/build/src/sdlayer.c @@ -59,7 +59,7 @@ static unsigned short sysgamma[3][256]; extern int curbrightness, gammabrightness; #ifdef USE_OPENGL // OpenGL stuff -static char nogl=0; +char nogl=0; #endif int vsync=0; diff --git a/polymer/build/src/winlayer.c b/polymer/build/src/winlayer.c index 6e7149d23..69b42c835 100644 --- a/polymer/build/src/winlayer.c +++ b/polymer/build/src/winlayer.c @@ -67,7 +67,8 @@ extern int curbrightness, gammabrightness; // OpenGL stuff static HGLRC hGLRC = 0; char nofog=0; -static char nogl=0; +char nogl=0; +char forcegl=0; #endif static LPTSTR GetWindowsErrorMsg(DWORD code); @@ -382,6 +383,8 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC #if defined(USE_OPENGL) && defined(POLYMOST) if ((argp = Bgetenv("BUILD_NOFOG")) != NULL) nofog = Batol(argp); + if (Bgetenv("BUILD_FORCEGL") != NULL) + forcegl = 1; #endif // install signal handlers @@ -1402,7 +1405,7 @@ static void GetKeyNames(void) tbuf[0] = 0; GetKeyNameText((i>128?(i+128):i)<<16, tbuf, sizeof(keynames[i])-1); // initprintf("%d %15s %15s\n",i,keynames[i],tbuf); - if(*tbuf)strncpy((char *)keynames[i], tbuf, sizeof(keynames[i])-1); + if(*tbuf)strncpy(&keynames[i][0], tbuf, sizeof(keynames[i])-1); } } @@ -2248,7 +2251,8 @@ void getvalidmodes(void) HRESULT result; #if defined(USE_OPENGL) && defined(POLYMOST) - if (desktopbpp > 8) cdepths[1] = desktopbpp; + if (desktopbpp > 8 && !nogl) cdepths[1] = desktopbpp; + else cdepths[1] = 0; #endif if (modeschecked) return; @@ -3257,12 +3261,31 @@ static int SetupOpenGL(int width, int height, int bitspp) { GLubyte *p,*p2,*p3; + int err = 0; glinfo.vendor = (char *)bglGetString(GL_VENDOR); glinfo.renderer = (char *)bglGetString(GL_RENDERER); glinfo.version = (char *)bglGetString(GL_VERSION); glinfo.extensions = (char *)bglGetString(GL_EXTENSIONS); + // GL driver blacklist + if (!forcegl) + { + if (!Bstrcmp(glinfo.vendor,"Microsoft Corporation")) err = 1; + else if (!Bstrcmp(glinfo.vendor,"SiS")) err = 1; + else if (!Bstrcmp(glinfo.vendor,"3Dfx Interactive Inc.")) err = 1; + + if (err) + { + OSD_Printf("Unsupported OpenGL driver. GL modes will be unavailable.\n"); + ReleaseOpenGL(); + nogl = 1; + modeschecked = 0; + getvalidmodes(); + return TRUE; + } + } + glinfo.maxanisotropy = 1.0; glinfo.bgra = 0; glinfo.texcompr = 0; diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 7237d1355..7cd32df94 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -10990,19 +10990,26 @@ void app_main(int argc,const char **argv) if (setgamemode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP) < 0) { - int i = 0; - int xres[] = {800,640,320}; - int yres[] = {600,480,240}; + int i = 0, j = 0; + int xres[] = {ud.config.ScreenWidth,800,640,320}; + int yres[] = {ud.config.ScreenHeight,600,480,240}; int bpp[] = {32,16,8}; initprintf("Failure setting video mode %dx%dx%d %s! Attempting safer mode...\n", ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP,ud.config.ScreenMode?"fullscreen":"windowed"); #if defined(POLYMOST) && defined(USE_OPENGL) - while (setgamemode(0,xres[i],yres[i],bpp[i]) < 0) + while (setgamemode(0,xres[i],yres[i],bpp[j]) < 0) { initprintf("Failure setting video mode %dx%dx%d windowed! Attempting safer mode...\n",xres[i],yres[i],bpp[i]); - i++; + j++; + if (j == 3) + { + i++; + j = 0; + } + if (i == 4) + gameexit("Unable to set failsafe video mode!"); } #else while (setgamemode(0,xres[i],yres[i],8) < 0)