mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
gl-color-mask
This commit is contained in:
parent
0c6e867d50
commit
749933b6e3
@ -81,20 +81,10 @@ bool gl_supports_bgr = config_glgsg.GetBool("gl-supports-bgr", false);
|
|||||||
bool gl_supports_bgr = false;
|
bool gl_supports_bgr = false;
|
||||||
#endif // GL_BGR
|
#endif // GL_BGR
|
||||||
|
|
||||||
GLDecalType gl_decal_type = GDT_offset;
|
// Configure this false if your GL's implementation of glColorMask()
|
||||||
|
// is broken (some are). This will force the use of a (presumably)
|
||||||
static GLDecalType
|
// more expensive blending operation instead.
|
||||||
parse_decal_type(const string &type) {
|
bool gl_color_mask = config_glgsg.GetBool("gl-color-mask", true);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigureFn(config_glgsg) {
|
ConfigureFn(config_glgsg) {
|
||||||
init_libglgsg();
|
init_libglgsg();
|
||||||
@ -116,11 +106,6 @@ init_libglgsg() {
|
|||||||
}
|
}
|
||||||
initialized = true;
|
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();
|
GLGraphicsStateGuardian::init_type();
|
||||||
GLSavedFrameBuffer::init_type();
|
GLSavedFrameBuffer::init_type();
|
||||||
GLTextureContext::init_type();
|
GLTextureContext::init_type();
|
||||||
|
@ -34,14 +34,7 @@ extern bool gl_save_mipmaps;
|
|||||||
extern bool gl_auto_normalize_lighting;
|
extern bool gl_auto_normalize_lighting;
|
||||||
extern bool gl_depth_offset_decals;
|
extern bool gl_depth_offset_decals;
|
||||||
extern bool gl_supports_bgr;
|
extern bool gl_supports_bgr;
|
||||||
|
extern bool gl_color_mask;
|
||||||
// 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 EXPCL_PANDAGL void init_libglgsg();
|
extern EXPCL_PANDAGL void init_libglgsg();
|
||||||
|
@ -287,7 +287,7 @@ call_glStencilFunc(GLenum func,GLint ref,GLuint mask) {
|
|||||||
glgsg_cat.debug(false) << "unknown, ";
|
glgsg_cat.debug(false) << "unknown, ";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
glgsg_cat.debug(false) << ref << mask << ")\n";
|
glgsg_cat.debug(false) << (int)ref << (unsigned int)mask << ")\n";
|
||||||
#endif
|
#endif
|
||||||
glStencilFunc(func, ref, mask);
|
glStencilFunc(func, ref, mask);
|
||||||
}
|
}
|
||||||
|
@ -2134,6 +2134,7 @@ issue_color_write(const ColorWriteAttrib *attrib) {
|
|||||||
// in set_blend_mode(). However, since GL does support an easy way
|
// in set_blend_mode(). However, since GL does support an easy way
|
||||||
// to disable writes to the color buffer, we can take advantage of
|
// to disable writes to the color buffer, we can take advantage of
|
||||||
// it here.
|
// it here.
|
||||||
|
if (gl_color_mask) {
|
||||||
ColorWriteAttrib::Mode mode = attrib->get_mode();
|
ColorWriteAttrib::Mode mode = attrib->get_mode();
|
||||||
if (mode == ColorWriteAttrib::M_off) {
|
if (mode == ColorWriteAttrib::M_off) {
|
||||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||||
@ -2141,6 +2142,12 @@ issue_color_write(const ColorWriteAttrib *attrib) {
|
|||||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
}
|
}
|
||||||
report_errors();
|
report_errors();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Some implementations don't seem to handle glColorMask() very
|
||||||
|
// robustly, however, so we provide this fallback.
|
||||||
|
GraphicsStateGuardian::issue_color_write(attrib);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PandaCompareFunc - 1 + 0x200 === GL_NEVER, etc. order is sequential
|
// PandaCompareFunc - 1 + 0x200 === GL_NEVER, etc. order is sequential
|
||||||
|
Loading…
x
Reference in New Issue
Block a user