Skip to content

Commit

Permalink
Partial implementation of color key blending
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Mar 23, 2024
1 parent eb0d44f commit 53b7309
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Dllmain/BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 6977
#define BUILD_NUMBER 6978
9 changes: 7 additions & 2 deletions ddraw/IDirect3DDeviceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2227,6 +2227,9 @@ HRESULT m_IDirect3DDeviceX::SetRenderState(D3DRENDERSTATETYPE dwRenderStateType,
case D3DRENDERSTATE_ALPHABLENDENABLE:
rsAlphaBlendEnabled = dwRenderState;
break;
case D3DRENDERSTATE_SRCBLEND:
rsSrcBlend = dwRenderState;
break;
case D3DRENDERSTATE_COLORKEYENABLE:
rsColorKeyEnabled = dwRenderState;
return D3D_OK;
Expand Down Expand Up @@ -3356,10 +3359,12 @@ inline void m_IDirect3DDeviceX::UpdateDrawFlags(DWORD& dwFlags)
// You can use D3DRENDERSTATE_COLORKEYENABLE render state with D3DRENDERSTATE_ALPHABLENDENABLE to implement fine blending control.
if (rsColorKeyEnabled && rsAlphaBlendEnabled)
{
LOG_LIMIT(100, __FUNCTION__ << " Warning: mixing color keying with alpha blending is not implemented!");
LOG_LIMIT(100, __FUNCTION__ << " Warning: mixing color keying with alpha blending is not implemented: " << rsSrcBlend);
}

// Check for color key
else if (rsColorKeyEnabled && CurrentTextureSurfaceX && CurrentTextureSurfaceX->GetColorKeyForShader(DrawStates.lowColorKey, DrawStates.highColorKey))
if (rsColorKeyEnabled && !(rsAlphaBlendEnabled && rsSrcBlend == D3DBLEND_ONE) &&
CurrentTextureSurfaceX && CurrentTextureSurfaceX->GetColorKeyForShader(DrawStates.lowColorKey, DrawStates.highColorKey))
{
dwFlags |= D3DDP_DXW_COLORKEYENABLE;
}
Expand Down
1 change: 1 addition & 0 deletions ddraw/IDirect3DDeviceX.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class m_IDirect3DDeviceX : public IUnknown, public AddressLookupTableDdrawObject

// Render states
DWORD rsAlphaBlendEnabled = FALSE;
DWORD rsSrcBlend = 0;
DWORD rsColorKeyEnabled = FALSE;

// SetTexture array
Expand Down

0 comments on commit 53b7309

Please sign in to comment.