From 7d20aff6f6ce46fb20bafcce32f7097344fd3c18 Mon Sep 17 00:00:00 2001 From: cxgeorge <> Date: Tue, 14 May 2002 21:25:16 +0000 Subject: [PATCH] use colorwritemask better --- panda/src/dxgsg8/dxGraphicsStateGuardian8.I | 11 ++++++++++- panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx | 7 ++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.I b/panda/src/dxgsg8/dxGraphicsStateGuardian8.I index d1513a4f6e..26df09063b 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.I +++ b/panda/src/dxgsg8/dxGraphicsStateGuardian8.I @@ -157,7 +157,16 @@ INLINE void DXGraphicsStateGuardian:: set_color_writemask(UINT color_writemask) { if (_color_writemask != color_writemask) { _color_writemask = color_writemask; - scrn.pD3DDevice->SetRenderState(D3DRS_COLORWRITEENABLE, (DWORD)color_writemask); + if(scrn.d3dcaps.PrimitiveMiscCaps & D3DPMISCCAPS_COLORWRITEENABLE) { + // only newer HW supports this rstate + scrn.pD3DDevice->SetRenderState(D3DRS_COLORWRITEENABLE, (DWORD)color_writemask); + } else { + assert((color_writemask==0x0)||(color_writemask==0xFFFFFFFF)); + if(color_writemask==0x0) { + enable_blend(true); + call_dxBlendFunc(D3DBLEND_ZERO, D3DBLEND_ONE); + } else enable_blend(false); + } } } diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx index 44ce8d2562..152f717b82 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx +++ b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx @@ -4381,13 +4381,10 @@ void DXGraphicsStateGuardian:: set_blend_mode(ColorWriteAttrib::Mode color_write_mode, ColorBlendAttrib::Mode color_blend_mode, TransparencyAttrib::Mode transparency_mode) { - // If color_write_mode is off, we disable writing to the color using - // blending. I don't know if it is possible in DX to disable color - // outside of a blend mode. + // If color_write_mode is off, we disable writing to the colorbuffer. if (color_write_mode == ColorWriteAttrib::M_off) { - enable_blend(true); enable_alpha_test(false); - call_dxBlendFunc(D3DBLEND_ZERO, D3DBLEND_ONE); + set_color_writemask(0x0); return; }