From 13873b985c6fdd00a661c0002deb5677cffbd667 Mon Sep 17 00:00:00 2001 From: plagman Date: Wed, 30 Sep 2009 01:26:13 +0000 Subject: [PATCH] Checks for required GPU/OpenGL functionality when initializing Polymer and fallbacks to Polymost if appropriate. This should prevent crashes when trying to run Polymer on older GPUs/drivers. git-svn-id: https://svn.eduke32.com/eduke32@1506 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/baselayer.h | 16 ++++--- polymer/eduke32/build/src/baselayer.c | 54 +++++++++++++---------- polymer/eduke32/build/src/engine.c | 10 ++++- polymer/eduke32/build/src/polymer.c | 15 +++++++ polymer/eduke32/build/src/sdlayer.c | 8 ++++ polymer/eduke32/build/src/winlayer.c | 8 ++++ 6 files changed, 78 insertions(+), 33 deletions(-) diff --git a/polymer/eduke32/build/include/baselayer.h b/polymer/eduke32/build/include/baselayer.h index a1d3fb388..664313be2 100644 --- a/polymer/eduke32/build/include/baselayer.h +++ b/polymer/eduke32/build/include/baselayer.h @@ -44,13 +44,13 @@ struct glinfo { const char *version; const char *extensions; - float maxanisotropy; - char bgra; - char clamptoedge; - char texcompr; - char texnpot; - char multisample; - char nvmultisamplehint; + float maxanisotropy; + char bgra; + char clamptoedge; + char texcompr; + char texnpot; + char multisample; + char nvmultisamplehint; char arbfp; char depthtex; char shadow; @@ -61,6 +61,8 @@ struct glinfo { char vbos; char vsync; char sm4; + char occlusionqueries; + char glsl; char dumped; }; diff --git a/polymer/eduke32/build/src/baselayer.c b/polymer/eduke32/build/src/baselayer.c index 9adcd08eb..7a00ff4e9 100644 --- a/polymer/eduke32/build/src/baselayer.c +++ b/polymer/eduke32/build/src/baselayer.c @@ -24,29 +24,31 @@ char scantoasc[128] = #ifdef USE_OPENGL struct glinfo glinfo = { - "Unknown", // vendor - "Unknown", // renderer - "0.0.0", // version - "", // extensions + "Unknown", // vendor + "Unknown", // renderer + "0.0.0", // version + "", // extensions - 1.0, // max anisotropy - 0, // brga texture format - 0, // clamp-to-edge support - 0, // texture compression - 0, // non-power-of-two textures - 0, // multisampling - 0, // nvidia multisampling hint - 0, // ARBfp - 0, // depth textures - 0, // shadow comparison - 0, // Frame Buffer Objects - 0, // rectangle textures - 0, // multitexturing - 0, // env_combine - 0, // Vertex Buffer Objects - 0, // VSync support - 0, // Shader Model 4 support - 0, // GL info dumped + 1.0, // max anisotropy + 0, // brga texture format + 0, // clamp-to-edge support + 0, // texture compression + 0, // non-power-of-two textures + 0, // multisampling + 0, // nvidia multisampling hint + 0, // ARBfp + 0, // depth textures + 0, // shadow comparison + 0, // Frame Buffer Objects + 0, // rectangle textures + 0, // multitexturing + 0, // env_combine + 0, // Vertex Buffer Objects + 0, // VSync support + 0, // Shader Model 4 support + 0, // Occlusion Queries + 0, // GLSL + 0, // GL info dumped }; #endif @@ -135,7 +137,7 @@ int32_t osdcmd_glinfo(const osdfuncparm_t *parm) initprintf(" Maximum anisotropy: %.1f%s\n" " BGRA textures: %s\n" - " Non-x^2 textures: %s\n" + " Non-power-of-2 textures: %s\n" " Texure compression: %s\n" " Clamp-to-edge: %s\n" " Multisampling: %s\n" @@ -149,6 +151,8 @@ int32_t osdcmd_glinfo(const osdfuncparm_t *parm) " env_combine: %s\n" " Vertex Buffer Objects: %s\n" " Shader Model 4: %s\n" + " Occlusion queries: %s\n" + " GLSL: %s\n" " Extensions:\n", glinfo.maxanisotropy, glinfo.maxanisotropy>1.0?"":" (no anisotropic filtering)", glinfo.bgra ? "supported": "not supported", @@ -165,7 +169,9 @@ int32_t osdcmd_glinfo(const osdfuncparm_t *parm) glinfo.multitex ? "supported": "not supported", glinfo.envcombine ? "supported": "not supported", glinfo.vbos ? "supported": "not supported", - glinfo.sm4 ? "supported": "not supported" + glinfo.sm4 ? "supported": "not supported", + glinfo.occlusionqueries ? "supported": "not supported", + glinfo.glsl ? "supported": "not supported" ); s = Bstrdup(glinfo.extensions); diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 401a237cf..3bae3614e 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -7731,7 +7731,10 @@ int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t da } # ifdef POLYMER if (rendmode == 4) - polymer_init(); + { + if (!polymer_init()) + rendmode = 3; + } #endif #endif qsetmode = 200; @@ -11944,7 +11947,10 @@ int32_t setrendermode(int32_t renderer) else renderer = min(4,max(3,renderer)); if (renderer == 4) - polymer_init(); + { + if (!polymer_init()) + renderer = 3; + } # else else renderer = 3; # endif diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index 678ff91f9..8d7302a5b 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -590,6 +590,21 @@ int32_t polymer_init(void) if (pr_verbosity >= 1) OSD_Printf("Initializing Polymer subsystem...\n"); + if (!glinfo.texnpot || + !glinfo.depthtex || + !glinfo.shadow || + !glinfo.fbos || + !glinfo.rect || + !glinfo.multitex || + !glinfo.vbos || + !glinfo.occlusionqueries || + !glinfo.glsl) + { + OSD_Printf("PR : Your video card driver/combo doesn't support the necessary features!\n"); + OSD_Printf("PR : Disabling Polymer...\n"); + return (0); + } + polymer_pool = nedcreatepool(POLYMER_POOL_SIZE, 0); Bmemset(&prsectors[0], 0, sizeof(prsectors[0]) * MAXSECTORS); diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index 16ef70f72..28cdf41a6 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -1235,6 +1235,14 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs) { glinfo.sm4 = 1; } + else if (!Bstrcmp((char *)p2, "GL_ARB_occlusion_query")) + { + glinfo.occlusionqueries = 1; + } + else if (!Bstrcmp((char *)p2, "GL_ARB_shader_objects")) + { + glinfo.glsl = 1; + } } Bfree(p); diff --git a/polymer/eduke32/build/src/winlayer.c b/polymer/eduke32/build/src/winlayer.c index b84448a4a..22b7ff549 100644 --- a/polymer/eduke32/build/src/winlayer.c +++ b/polymer/eduke32/build/src/winlayer.c @@ -3503,6 +3503,14 @@ static int32_t SetupOpenGL(int32_t width, int32_t height, int32_t bitspp) { glinfo.sm4 = 1; } + else if (!Bstrcmp((char *)p2, "GL_ARB_occlusion_query")) + { + glinfo.occlusionqueries = 1; + } + else if (!Bstrcmp((char *)p2, "GL_ARB_shader_objects")) + { + glinfo.glsl = 1; + } } Bfree(p); }