|
@@ -1817,134 +1817,6 @@ do_issue_texture() {
|
|
|
*/
|
|
*/
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-// Function: TinyGraphicsStateGuardian::do_issue_blending
|
|
|
|
|
-// Access: Protected
|
|
|
|
|
-// Description:
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-void TinyGraphicsStateGuardian::
|
|
|
|
|
-do_issue_blending() {
|
|
|
|
|
- /*
|
|
|
|
|
- // Handle the color_write attrib. If color_write is off, then
|
|
|
|
|
- // all the other blending-related stuff doesn't matter. If the
|
|
|
|
|
- // device doesn't support color-write, we use blending tricks
|
|
|
|
|
- // to effectively disable color write.
|
|
|
|
|
- unsigned int color_channels =
|
|
|
|
|
- _target._color_write->get_channels() & _color_write_mask;
|
|
|
|
|
- if (color_channels == ColorWriteAttrib::C_off) {
|
|
|
|
|
- if (_target._color_write != _state._color_write) {
|
|
|
|
|
- enable_multisample_alpha_one(false);
|
|
|
|
|
- enable_multisample_alpha_mask(false);
|
|
|
|
|
- if (CLP(color_mask)) {
|
|
|
|
|
- enable_blend(false);
|
|
|
|
|
- glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
|
|
|
|
- } else {
|
|
|
|
|
- enable_blend(true);
|
|
|
|
|
- _glBlendEquation(GL_FUNC_ADD);
|
|
|
|
|
- glBlendFunc(GL_ZERO, GL_ONE);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return;
|
|
|
|
|
- } else {
|
|
|
|
|
- if (_target._color_write != _state._color_write) {
|
|
|
|
|
- if (CLP(color_mask)) {
|
|
|
|
|
- glColorMask((color_channels & ColorWriteAttrib::C_red) != 0,
|
|
|
|
|
- (color_channels & ColorWriteAttrib::C_green) != 0,
|
|
|
|
|
- (color_channels & ColorWriteAttrib::C_blue) != 0,
|
|
|
|
|
- (color_channels & ColorWriteAttrib::C_alpha) != 0);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- CPT(ColorBlendAttrib) color_blend = _target._color_blend;
|
|
|
|
|
- ColorBlendAttrib::Mode color_blend_mode = _target._color_blend->get_mode();
|
|
|
|
|
- TransparencyAttrib::Mode transparency_mode = _target._transparency->get_mode();
|
|
|
|
|
-
|
|
|
|
|
- _color_blend_involves_color_scale = color_blend->involves_color_scale();
|
|
|
|
|
-
|
|
|
|
|
- // Is there a color blend set?
|
|
|
|
|
- if (color_blend_mode != ColorBlendAttrib::M_none) {
|
|
|
|
|
- enable_multisample_alpha_one(false);
|
|
|
|
|
- enable_multisample_alpha_mask(false);
|
|
|
|
|
- enable_blend(true);
|
|
|
|
|
- _glBlendEquation(get_blend_equation_type(color_blend_mode));
|
|
|
|
|
- glBlendFunc(get_blend_func(color_blend->get_operand_a()),
|
|
|
|
|
- get_blend_func(color_blend->get_operand_b()));
|
|
|
|
|
-
|
|
|
|
|
- if (_color_blend_involves_color_scale) {
|
|
|
|
|
- // Apply the current color scale to the blend mode.
|
|
|
|
|
- _glBlendColor(_current_color_scale[0], _current_color_scale[1],
|
|
|
|
|
- _current_color_scale[2], _current_color_scale[3]);
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
- Colorf c = color_blend->get_color();
|
|
|
|
|
- _glBlendColor(c[0], c[1], c[2], c[3]);
|
|
|
|
|
- }
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // No color blend; is there a transparency set?
|
|
|
|
|
- switch (transparency_mode) {
|
|
|
|
|
- case TransparencyAttrib::M_none:
|
|
|
|
|
- case TransparencyAttrib::M_binary:
|
|
|
|
|
- break;
|
|
|
|
|
-
|
|
|
|
|
- case TransparencyAttrib::M_alpha:
|
|
|
|
|
- case TransparencyAttrib::M_dual:
|
|
|
|
|
- enable_multisample_alpha_one(false);
|
|
|
|
|
- enable_multisample_alpha_mask(false);
|
|
|
|
|
- enable_blend(true);
|
|
|
|
|
- _glBlendEquation(GL_FUNC_ADD);
|
|
|
|
|
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- case TransparencyAttrib::M_multisample:
|
|
|
|
|
- // We need to enable *both* of these in M_multisample case.
|
|
|
|
|
- enable_multisample_alpha_one(true);
|
|
|
|
|
- enable_multisample_alpha_mask(true);
|
|
|
|
|
- enable_blend(false);
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- case TransparencyAttrib::M_multisample_mask:
|
|
|
|
|
- enable_multisample_alpha_one(false);
|
|
|
|
|
- enable_multisample_alpha_mask(true);
|
|
|
|
|
- enable_blend(false);
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- default:
|
|
|
|
|
- tinydisplay_cat.error()
|
|
|
|
|
- << "invalid transparency mode " << (int)transparency_mode << endl;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (_line_smooth_enabled || _point_smooth_enabled) {
|
|
|
|
|
- // If we have either of these turned on, we also need to have
|
|
|
|
|
- // blend mode enabled in order to see it.
|
|
|
|
|
- enable_multisample_alpha_one(false);
|
|
|
|
|
- enable_multisample_alpha_mask(false);
|
|
|
|
|
- enable_blend(true);
|
|
|
|
|
- _glBlendEquation(GL_FUNC_ADD);
|
|
|
|
|
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // For best polygon smoothing, we need:
|
|
|
|
|
- // (1) a frame buffer that supports alpha
|
|
|
|
|
- // (2) sort polygons front-to-back
|
|
|
|
|
- // (3) glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE);
|
|
|
|
|
- //
|
|
|
|
|
- // Since these modes have other implications for the application, we
|
|
|
|
|
- // don't attempt to do this by default. If you really want good
|
|
|
|
|
- // polygon smoothing (and you don't have multisample support), do
|
|
|
|
|
- // all this yourself.
|
|
|
|
|
-
|
|
|
|
|
- // Nothing's set, so disable blending.
|
|
|
|
|
- enable_multisample_alpha_one(false);
|
|
|
|
|
- enable_multisample_alpha_mask(false);
|
|
|
|
|
- enable_blend(false);
|
|
|
|
|
- */
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: TinyGraphicsStateGuardian::apply_texture
|
|
// Function: TinyGraphicsStateGuardian::apply_texture
|
|
|
// Access: Protected
|
|
// Access: Protected
|