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
This commit is contained in:
plagman 2009-09-30 01:26:13 +00:00
parent 10913b51f2
commit 13873b985c
6 changed files with 78 additions and 33 deletions

View file

@ -44,13 +44,13 @@ struct glinfo {
const char *version; const char *version;
const char *extensions; const char *extensions;
float maxanisotropy; float maxanisotropy;
char bgra; char bgra;
char clamptoedge; char clamptoedge;
char texcompr; char texcompr;
char texnpot; char texnpot;
char multisample; char multisample;
char nvmultisamplehint; char nvmultisamplehint;
char arbfp; char arbfp;
char depthtex; char depthtex;
char shadow; char shadow;
@ -61,6 +61,8 @@ struct glinfo {
char vbos; char vbos;
char vsync; char vsync;
char sm4; char sm4;
char occlusionqueries;
char glsl;
char dumped; char dumped;
}; };

View file

@ -24,29 +24,31 @@ char scantoasc[128] =
#ifdef USE_OPENGL #ifdef USE_OPENGL
struct glinfo glinfo = struct glinfo glinfo =
{ {
"Unknown", // vendor "Unknown", // vendor
"Unknown", // renderer "Unknown", // renderer
"0.0.0", // version "0.0.0", // version
"", // extensions "", // extensions
1.0, // max anisotropy 1.0, // max anisotropy
0, // brga texture format 0, // brga texture format
0, // clamp-to-edge support 0, // clamp-to-edge support
0, // texture compression 0, // texture compression
0, // non-power-of-two textures 0, // non-power-of-two textures
0, // multisampling 0, // multisampling
0, // nvidia multisampling hint 0, // nvidia multisampling hint
0, // ARBfp 0, // ARBfp
0, // depth textures 0, // depth textures
0, // shadow comparison 0, // shadow comparison
0, // Frame Buffer Objects 0, // Frame Buffer Objects
0, // rectangle textures 0, // rectangle textures
0, // multitexturing 0, // multitexturing
0, // env_combine 0, // env_combine
0, // Vertex Buffer Objects 0, // Vertex Buffer Objects
0, // VSync support 0, // VSync support
0, // Shader Model 4 support 0, // Shader Model 4 support
0, // GL info dumped 0, // Occlusion Queries
0, // GLSL
0, // GL info dumped
}; };
#endif #endif
@ -135,7 +137,7 @@ int32_t osdcmd_glinfo(const osdfuncparm_t *parm)
initprintf(" Maximum anisotropy: %.1f%s\n" initprintf(" Maximum anisotropy: %.1f%s\n"
" BGRA textures: %s\n" " BGRA textures: %s\n"
" Non-x^2 textures: %s\n" " Non-power-of-2 textures: %s\n"
" Texure compression: %s\n" " Texure compression: %s\n"
" Clamp-to-edge: %s\n" " Clamp-to-edge: %s\n"
" Multisampling: %s\n" " Multisampling: %s\n"
@ -149,6 +151,8 @@ int32_t osdcmd_glinfo(const osdfuncparm_t *parm)
" env_combine: %s\n" " env_combine: %s\n"
" Vertex Buffer Objects: %s\n" " Vertex Buffer Objects: %s\n"
" Shader Model 4: %s\n" " Shader Model 4: %s\n"
" Occlusion queries: %s\n"
" GLSL: %s\n"
" Extensions:\n", " Extensions:\n",
glinfo.maxanisotropy, glinfo.maxanisotropy>1.0?"":" (no anisotropic filtering)", glinfo.maxanisotropy, glinfo.maxanisotropy>1.0?"":" (no anisotropic filtering)",
glinfo.bgra ? "supported": "not supported", glinfo.bgra ? "supported": "not supported",
@ -165,7 +169,9 @@ int32_t osdcmd_glinfo(const osdfuncparm_t *parm)
glinfo.multitex ? "supported": "not supported", glinfo.multitex ? "supported": "not supported",
glinfo.envcombine ? "supported": "not supported", glinfo.envcombine ? "supported": "not supported",
glinfo.vbos ? "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); s = Bstrdup(glinfo.extensions);

View file

@ -7731,7 +7731,10 @@ int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t da
} }
# ifdef POLYMER # ifdef POLYMER
if (rendmode == 4) if (rendmode == 4)
polymer_init(); {
if (!polymer_init())
rendmode = 3;
}
#endif #endif
#endif #endif
qsetmode = 200; qsetmode = 200;
@ -11944,7 +11947,10 @@ int32_t setrendermode(int32_t renderer)
else renderer = min(4,max(3,renderer)); else renderer = min(4,max(3,renderer));
if (renderer == 4) if (renderer == 4)
polymer_init(); {
if (!polymer_init())
renderer = 3;
}
# else # else
else renderer = 3; else renderer = 3;
# endif # endif

View file

@ -590,6 +590,21 @@ int32_t polymer_init(void)
if (pr_verbosity >= 1) OSD_Printf("Initializing Polymer subsystem...\n"); 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); polymer_pool = nedcreatepool(POLYMER_POOL_SIZE, 0);
Bmemset(&prsectors[0], 0, sizeof(prsectors[0]) * MAXSECTORS); Bmemset(&prsectors[0], 0, sizeof(prsectors[0]) * MAXSECTORS);

View file

@ -1235,6 +1235,14 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs)
{ {
glinfo.sm4 = 1; 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); Bfree(p);

View file

@ -3503,6 +3503,14 @@ static int32_t SetupOpenGL(int32_t width, int32_t height, int32_t bitspp)
{ {
glinfo.sm4 = 1; 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); Bfree(p);
} }