diff --git a/panda/src/glgsg/config_glgsg.cxx b/panda/src/glgsg/config_glgsg.cxx index 7ce74499cb..3f141ad275 100644 --- a/panda/src/glgsg/config_glgsg.cxx +++ b/panda/src/glgsg/config_glgsg.cxx @@ -81,20 +81,10 @@ bool gl_supports_bgr = config_glgsg.GetBool("gl-supports-bgr", false); bool gl_supports_bgr = false; #endif // GL_BGR -GLDecalType gl_decal_type = GDT_offset; - -static GLDecalType -parse_decal_type(const string &type) { - if (type == "mask") { - return GDT_mask; - } else if (type == "blend") { - return GDT_blend; - } else if (type == "offset") { - return GDT_offset; - } - glgsg_cat.error() << "Invalid gl-decal-type: " << type << "\n"; - return GDT_offset; -} +// Configure this false if your GL's implementation of glColorMask() +// is broken (some are). This will force the use of a (presumably) +// more expensive blending operation instead. +bool gl_color_mask = config_glgsg.GetBool("gl-color-mask", true); ConfigureFn(config_glgsg) { init_libglgsg(); @@ -116,11 +106,6 @@ init_libglgsg() { } initialized = true; - string decal_type = config_glgsg.GetString("gl-decal-type", ""); - if (!decal_type.empty()) { - gl_decal_type = parse_decal_type(decal_type); - } - GLGraphicsStateGuardian::init_type(); GLSavedFrameBuffer::init_type(); GLTextureContext::init_type(); diff --git a/panda/src/glgsg/config_glgsg.h b/panda/src/glgsg/config_glgsg.h index 607bf0898b..e44d5f1f95 100644 --- a/panda/src/glgsg/config_glgsg.h +++ b/panda/src/glgsg/config_glgsg.h @@ -34,14 +34,7 @@ extern bool gl_save_mipmaps; extern bool gl_auto_normalize_lighting; extern bool gl_depth_offset_decals; extern bool gl_supports_bgr; - -// Ways to implement decals. -enum GLDecalType { - GDT_mask, // GL 1.0 style, involving three steps - GDT_blend, // As above, but slower; a hack for broken nVidia driver - GDT_offset // The fastest, using GL 1.1 style glPolygonOffset -}; -extern GLDecalType gl_decal_type; +extern bool gl_color_mask; extern EXPCL_PANDAGL void init_libglgsg(); diff --git a/panda/src/glgsg/glGraphicsStateGuardian.I b/panda/src/glgsg/glGraphicsStateGuardian.I index 3bf66fae65..4d11d7aeb2 100644 --- a/panda/src/glgsg/glGraphicsStateGuardian.I +++ b/panda/src/glgsg/glGraphicsStateGuardian.I @@ -287,7 +287,7 @@ call_glStencilFunc(GLenum func,GLint ref,GLuint mask) { glgsg_cat.debug(false) << "unknown, "; break; } - glgsg_cat.debug(false) << ref << mask << ")\n"; + glgsg_cat.debug(false) << (int)ref << (unsigned int)mask << ")\n"; #endif glStencilFunc(func, ref, mask); } diff --git a/panda/src/glgsg/glGraphicsStateGuardian.cxx b/panda/src/glgsg/glGraphicsStateGuardian.cxx index 81d39ac037..580599693d 100644 --- a/panda/src/glgsg/glGraphicsStateGuardian.cxx +++ b/panda/src/glgsg/glGraphicsStateGuardian.cxx @@ -2134,13 +2134,20 @@ issue_color_write(const ColorWriteAttrib *attrib) { // in set_blend_mode(). However, since GL does support an easy way // to disable writes to the color buffer, we can take advantage of // it here. - ColorWriteAttrib::Mode mode = attrib->get_mode(); - if (mode == ColorWriteAttrib::M_off) { - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + if (gl_color_mask) { + ColorWriteAttrib::Mode mode = attrib->get_mode(); + if (mode == ColorWriteAttrib::M_off) { + glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + } else { + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + } + report_errors(); + } else { - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + // Some implementations don't seem to handle glColorMask() very + // robustly, however, so we provide this fallback. + GraphicsStateGuardian::issue_color_write(attrib); } - report_errors(); } // PandaCompareFunc - 1 + 0x200 === GL_NEVER, etc. order is sequential