From 5a751d9c0da79b38d4104bbe0cc1b5feec3d6ecc Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sat, 29 Sep 2012 19:35:14 +0200 Subject: Fixed texture regression There was a bug in texture modesetting but only visible after certain mode changes. --- src/graphics/engine/engine.cpp | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'src/graphics/engine/engine.cpp') diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index e34034d..c094c63 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -1851,8 +1851,6 @@ void CEngine::SetState(int state, const Color& color) m_device->SetRenderState(RENDER_STATE_BLENDING, true); m_device->SetBlendFunc(BLEND_ONE, BLEND_INV_SRC_COLOR); - m_device->SetRenderState(RENDER_STATE_TEXTURING, true); - m_device->SetTextureFactor(color); TextureStageParams params; @@ -1873,8 +1871,6 @@ void CEngine::SetState(int state, const Color& color) m_device->SetRenderState(RENDER_STATE_BLENDING, true); m_device->SetBlendFunc(BLEND_DST_COLOR, BLEND_ZERO); - m_device->SetRenderState(RENDER_STATE_TEXTURING, true); - m_device->SetTextureFactor(color.Inverse()); TextureStageParams params; @@ -1891,20 +1887,22 @@ void CEngine::SetState(int state, const Color& color) m_device->SetRenderState(RENDER_STATE_FOG, false); m_device->SetRenderState(RENDER_STATE_DEPTH_WRITE, false); m_device->SetRenderState(RENDER_STATE_ALPHA_TEST, false); - m_device->SetRenderState(RENDER_STATE_TEXTURING, false); m_device->SetRenderState(RENDER_STATE_BLENDING, true); m_device->SetBlendFunc(BLEND_ONE, BLEND_INV_SRC_COLOR); + + m_device->SetTextureEnabled(0, false); } else if (state & ENG_RSTATE_TCOLOR_WHITE) // transparent white color? { m_device->SetRenderState(RENDER_STATE_FOG, false); m_device->SetRenderState(RENDER_STATE_DEPTH_WRITE, false); m_device->SetRenderState(RENDER_STATE_ALPHA_TEST, false); - m_device->SetRenderState(RENDER_STATE_TEXTURING, false); m_device->SetRenderState(RENDER_STATE_BLENDING, true); m_device->SetBlendFunc(BLEND_DST_COLOR, BLEND_ZERO); + + m_device->SetTextureEnabled(0, false); } else if (state & ENG_RSTATE_TDIFFUSE) // diffuse color as transparent? { @@ -1915,8 +1913,6 @@ void CEngine::SetState(int state, const Color& color) m_device->SetRenderState(RENDER_STATE_BLENDING, true); m_device->SetBlendFunc(BLEND_SRC_ALPHA, BLEND_DST_ALPHA); - m_device->SetRenderState(RENDER_STATE_TEXTURING, true); - TextureStageParams params; params.colorOperation = TEX_MIX_OPER_REPLACE; params.colorArg1 = TEX_MIX_ARG_TEXTURE; @@ -1932,7 +1928,6 @@ void CEngine::SetState(int state, const Color& color) m_device->SetRenderState(RENDER_STATE_ALPHA_TEST, false); m_device->SetRenderState(RENDER_STATE_BLENDING, false); - m_device->SetRenderState(RENDER_STATE_TEXTURING, true); m_device->SetTextureEnabled(0, true); m_device->SetTextureStageParams(0, TextureStageParams()); // default operation } @@ -1942,7 +1937,8 @@ void CEngine::SetState(int state, const Color& color) m_device->SetRenderState(RENDER_STATE_DEPTH_WRITE, false); m_device->SetRenderState(RENDER_STATE_ALPHA_TEST, false); m_device->SetRenderState(RENDER_STATE_BLENDING, false); - m_device->SetRenderState(RENDER_STATE_TEXTURING, false); + + m_device->SetTextureEnabled(0, false); } else if (state & ENG_RSTATE_TEXT) // font rendering? { @@ -1953,7 +1949,6 @@ void CEngine::SetState(int state, const Color& color) m_device->SetRenderState(RENDER_STATE_BLENDING, true); m_device->SetBlendFunc(BLEND_SRC_ALPHA, BLEND_INV_SRC_ALPHA); - m_device->SetRenderState(RENDER_STATE_TEXTURING, true); m_device->SetTextureEnabled(0, true); m_device->SetTextureStageParams(0, TextureStageParams()); // default operation } @@ -1968,8 +1963,6 @@ void CEngine::SetState(int state, const Color& color) m_device->SetAlphaTestFunc(COMP_FUNC_GREATER, 0.5f); - m_device->SetRenderState(RENDER_STATE_TEXTURING, true); - m_device->SetTextureFactor(color); TextureStageParams params; @@ -1990,8 +1983,6 @@ void CEngine::SetState(int state, const Color& color) m_device->SetRenderState(RENDER_STATE_DEPTH_WRITE, true); m_device->SetRenderState(RENDER_STATE_FOG, true); - m_device->SetRenderState(RENDER_STATE_TEXTURING, true); - TextureStageParams params; params.colorOperation = TEX_MIX_OPER_DEFAULT; // default modulate params.alphaOperation = TEX_MIX_OPER_DEFAULT; // TODO: replace with src color ? @@ -2063,9 +2054,7 @@ void CEngine::SetState(int state, const Color& color) // In interface mode, disable lighting if (m_interfaceMode) - { m_device->SetRenderState(RENDER_STATE_LIGHTING, false); - } } void CEngine::SetMaterial(const Material& mat) @@ -3584,7 +3573,6 @@ void CEngine::DrawOverColor() m_device->SetRenderState(RENDER_STATE_DEPTH_WRITE, false); m_device->SetRenderState(RENDER_STATE_LIGHTING, false); m_device->SetRenderState(RENDER_STATE_FOG, false); - m_device->SetRenderState(RENDER_STATE_TEXTURING, false); m_device->SetTransform(TRANSFORM_VIEW, m_matViewInterface); m_device->SetTransform(TRANSFORM_PROJECTION, m_matProjInterface); -- cgit v1.2.3-1-g7c22