mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-23 01:21:57 -05:00
Direct3D11: Fix 3D anaglyph not working
This commit is contained in:
parent
43a49d48cc
commit
4a96f653bf
1 changed files with 16 additions and 6 deletions
|
@ -886,10 +886,10 @@ void Gfx_DisableMipmaps(void) {
|
||||||
static ID3D11RenderTargetView* backbuffer;
|
static ID3D11RenderTargetView* backbuffer;
|
||||||
static ID3D11Texture2D* depthbuffer;
|
static ID3D11Texture2D* depthbuffer;
|
||||||
static ID3D11DepthStencilView* depthbufferView;
|
static ID3D11DepthStencilView* depthbufferView;
|
||||||
static ID3D11BlendState* om_blendStates[4];
|
static ID3D11BlendState* om_blendStates[16 * 2];
|
||||||
static ID3D11DepthStencilState* om_depthStates[4];
|
static ID3D11DepthStencilState* om_depthStates[4];
|
||||||
static float gfx_clearColor[4];
|
static float gfx_clearColor[4];
|
||||||
static cc_bool gfx_colorEnabled = true;
|
static cc_bool gfx_channels[4] = { true, true, true, true };
|
||||||
static cc_bool gfx_depthTest, gfx_depthWrite;
|
static cc_bool gfx_depthTest, gfx_depthWrite;
|
||||||
|
|
||||||
static void OM_Clear(GfxBuffers buffers) {
|
static void OM_Clear(GfxBuffers buffers) {
|
||||||
|
@ -971,8 +971,14 @@ static void OM_CreateBlendStates(void) {
|
||||||
|
|
||||||
for (int i = 0; i < Array_Elems(om_blendStates); i++)
|
for (int i = 0; i < Array_Elems(om_blendStates); i++)
|
||||||
{
|
{
|
||||||
desc.RenderTarget[0].RenderTargetWriteMask = (i & 1) ? D3D11_COLOR_WRITE_ENABLE_ALL : 0;
|
int mask = 0;
|
||||||
desc.RenderTarget[0].BlendEnable = (i & 2) != 0;
|
if (i & 0x01) mask |= D3D11_COLOR_WRITE_ENABLE_RED;
|
||||||
|
if (i & 0x02) mask |= D3D11_COLOR_WRITE_ENABLE_GREEN;
|
||||||
|
if (i & 0x04) mask |= D3D11_COLOR_WRITE_ENABLE_BLUE;
|
||||||
|
if (i & 0x08) mask |= D3D11_COLOR_WRITE_ENABLE_ALPHA;
|
||||||
|
|
||||||
|
desc.RenderTarget[0].RenderTargetWriteMask = mask;
|
||||||
|
desc.RenderTarget[0].BlendEnable = (i & 0x10) != 0;
|
||||||
|
|
||||||
hr = ID3D11Device_CreateBlendState(device, &desc, &om_blendStates[i]);
|
hr = ID3D11Device_CreateBlendState(device, &desc, &om_blendStates[i]);
|
||||||
if (hr) Logger_Abort2(hr, "Failed to create blend state");
|
if (hr) Logger_Abort2(hr, "Failed to create blend state");
|
||||||
|
@ -980,7 +986,8 @@ static void OM_CreateBlendStates(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OM_UpdateBlendState(void) {
|
static void OM_UpdateBlendState(void) {
|
||||||
ID3D11BlendState* blendState = om_blendStates[gfx_colorEnabled | (gfx_alphaBlend << 1)];
|
int idx = (gfx_channels[0]) | (gfx_channels[1] << 1) | (gfx_channels[2] << 2) | (gfx_channels[3] << 3) | (gfx_alphaBlend << 4);
|
||||||
|
ID3D11BlendState* blendState = om_blendStates[idx];
|
||||||
ID3D11DeviceContext_OMSetBlendState(context, blendState, NULL, 0xffffffff);
|
ID3D11DeviceContext_OMSetBlendState(context, blendState, NULL, 0xffffffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1034,7 +1041,10 @@ static void SetAlphaBlend(cc_bool enabled) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetColorWrite(cc_bool r, cc_bool g, cc_bool b, cc_bool a) {
|
static void SetColorWrite(cc_bool r, cc_bool g, cc_bool b, cc_bool a) {
|
||||||
gfx_colorEnabled = r;
|
gfx_channels[0] = r;
|
||||||
|
gfx_channels[1] = g;
|
||||||
|
gfx_channels[2] = b;
|
||||||
|
gfx_channels[3] = a;
|
||||||
OM_UpdateBlendState();
|
OM_UpdateBlendState();
|
||||||
// TODO all channels
|
// TODO all channels
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue