mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 18:03:56 -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;
|
||||
#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();
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user