diff --git a/DDrawCompat/D3dDdi/DeviceState.cpp b/DDrawCompat/D3dDdi/DeviceState.cpp index e8d4965..139ffb7 100644 --- a/DDrawCompat/D3dDdi/DeviceState.cpp +++ b/DDrawCompat/D3dDdi/DeviceState.cpp @@ -96,6 +96,25 @@ namespace D3dDdi HRESULT DeviceState::pfnSetTextureStageState(const D3DDDIARG_TEXTURESTAGESTATE* data) { + if (D3DDDITSS_TEXTURECOLORKEYVAL == data->State) + { + if (1 == m_textureStageState[data->Stage][D3DDDITSS_DISABLETEXTURECOLORKEY]) + { + m_textureStageState[data->Stage][D3DDDITSS_DISABLETEXTURECOLORKEY] = 0; + } + else if (data->Value == m_textureStageState[data->Stage][D3DDDITSS_TEXTURECOLORKEYVAL]) + { + return S_OK; + } + + m_device.flushPrimitives(); + HRESULT result = m_device.getOrigVtable().pfnSetTextureStageState(m_device, data); + if (SUCCEEDED(result)) + { + m_textureStageState[data->Stage][D3DDDITSS_TEXTURECOLORKEYVAL] = data->Value; + } + return result; + } return setStateArray(data, m_textureStageState[data->Stage], m_device.getOrigVtable().pfnSetTextureStageState); } diff --git a/DDrawCompat/D3dDdi/DeviceState.h b/DDrawCompat/D3dDdi/DeviceState.h index 4a084f5..fdf7931 100644 --- a/DDrawCompat/D3dDdi/DeviceState.h +++ b/DDrawCompat/D3dDdi/DeviceState.h @@ -59,7 +59,7 @@ namespace D3dDdi std::vector m_pixelShaderConstI; std::array m_renderState; std::array m_textures; - std::array, 8> m_textureStageState; + std::array, 8> m_textureStageState; std::vector m_vertexShaderConst; std::vector m_vertexShaderConstB; std::vector m_vertexShaderConstI;