diff -ur blobAndConquer-0.90/src/effects/shadows.cpp blobAndConquer-0.90.new/src/effects/shadows.cpp --- blobAndConquer-0.90/src/effects/shadows.cpp 2006-10-28 19:34:10.000000000 +0200 +++ blobAndConquer-0.90.new/src/effects/shadows.cpp 2007-05-20 18:40:56.000000000 +0200 @@ -126,6 +126,9 @@ void drawShadow() { + if (game->shadowPolicy == SHADOW_POLICY_OFF) + return; + generateShadows(); glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_POLYGON_BIT | GL_STENCIL_BUFFER_BIT); diff -ur blobAndConquer-0.90/src/hud/options.cpp blobAndConquer-0.90.new/src/hud/options.cpp --- blobAndConquer-0.90/src/hud/options.cpp 2007-04-24 09:32:01.000000000 +0200 +++ blobAndConquer-0.90.new/src/hud/options.cpp 2007-05-20 19:17:52.000000000 +0200 @@ -445,11 +445,16 @@ blood->addItem("Off"); blood->addItem("No Stains"); blood->addItem("On"); - - shadows->addItem("Off"); - shadows->addItem("Bob Only"); - shadows->addItem("Blobs and Enemies"); - shadows->addItem("On"); + + if (graphics->hasStencils) + { + shadows->addItem("Off"); + shadows->addItem("Bob Only"); + shadows->addItem("Blobs and Enemies"); + shadows->addItem("On"); + } + else + shadows->addItem("Not Available (no stencil support)"); decals->addItem("Off"); decals->addItem("Low"); diff -ur blobAndConquer-0.90/src/init.cpp blobAndConquer-0.90.new/src/init.cpp --- blobAndConquer-0.90/src/init.cpp 2007-04-24 09:32:01.000000000 +0200 +++ blobAndConquer-0.90.new/src/init.cpp 2007-05-20 19:13:32.000000000 +0200 @@ -278,9 +278,15 @@ glGetIntegerv(GL_STENCIL_BITS, &stencil); - if (stencil == 0) - { - graphics->showErrorAndExit("Stencil Buffering is not supported"); + /* update queried hasStencils value with the real thing */ + graphics->hasStencils = stencil; + if (!graphics->hasStencils) { + printf("Warning: Stencil Buffering is not supported,\n"); +#ifdef __unix__ + printf(" try changing your X-windows colordepth to 32bpp,\n"); +#endif + printf(" disabling shadows!\n"); + game->shadowPolicy = SHADOW_POLICY_OFF; } /* @@ -315,8 +321,13 @@ exit(1); } + graphics->queryStencilSupport(); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); + if (graphics->hasStencils) + SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); + else + SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); graphics->getAvailableScreenModes(); diff -ur blobAndConquer-0.90/src/system/CGraphics.cpp blobAndConquer-0.90.new/src/system/CGraphics.cpp --- blobAndConquer-0.90/src/system/CGraphics.cpp 2007-05-04 09:14:36.000000000 +0200 +++ blobAndConquer-0.90.new/src/system/CGraphics.cpp 2007-05-20 19:13:43.000000000 +0200 @@ -19,6 +19,10 @@ */ #include "../headers.h" +#ifdef __unix__ +#include +#include +#endif Graphics::Graphics() { @@ -135,6 +139,60 @@ } } +void Graphics::queryStencilSupport() +{ +#ifdef __unix__ + SDL_SysWMinfo wm_info; + + SDL_VERSION(&wm_info.version); + + if (SDL_GetWMInfo(&wm_info) && wm_info.subsystem == SDL_SYSWM_X11) + { + XVisualInfo theTemplate; + XVisualInfo *visuals; + int i, numVisuals, visualCaveat, stencilSize; + long mask = VisualScreenMask; + Display *dpy = wm_info.info.x11.display; + + wm_info.info.x11.lock_func(); + + theTemplate.screen = 0; + visuals = XGetVisualInfo(dpy, mask, &theTemplate, &numVisuals); + + hasStencils = false; + for(i = 0; i < numVisuals; i++) + { + const char *ext = glXQueryExtensionsString(dpy, visuals[i].screen); + + glXGetConfig(dpy, &visuals[i], GLX_STENCIL_SIZE, &stencilSize); + + if (ext && strstr(ext, "GLX_EXT_visual_rating")) { + glXGetConfig(dpy, &visuals[i], GLX_VISUAL_CAVEAT_EXT, &visualCaveat); + } + else { + visualCaveat = -1; /* unknown */ + } + + if (stencilSize && (visualCaveat == GLX_NONE_EXT)) { + hasStencils = true; + break; + } + } + wm_info.info.x11.unlock_func(); + debug(("Query stencil support: has stencils: %d\n", (int)hasStencils)); + } + else + { + printf("Warning: Couldn't determine the availability of stencil buffers (no X11 display),\n"); + printf(" assuming they are available\n"); + hasStencils = true; + } +#else + /* assume stencils are available on other platforms */ + hasStencils = true; +#endif +} + void Graphics::getAvailableScreenModes() { debug(("Graphics::getAvailableScreenModes()\n")); @@ -286,7 +344,10 @@ void Graphics::clearScreen() { - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + if (hasStencils) + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + else + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } void Graphics::updateScreen() diff -ur blobAndConquer-0.90/src/system/CGraphics.h blobAndConquer-0.90.new/src/system/CGraphics.h --- blobAndConquer-0.90/src/system/CGraphics.h 2007-01-04 18:39:32.000000000 +0100 +++ blobAndConquer-0.90.new/src/system/CGraphics.h 2007-05-20 19:12:40.000000000 +0200 @@ -76,6 +76,7 @@ int currentScreenResolution; bool fullscreen; + bool hasStencils; float gamma; int redPulseDir; @@ -85,6 +86,7 @@ ~Graphics(); void destroy(); + void queryStencilSupport(); void getAvailableScreenModes(); void setResolution(int i); void resetFPSCount();