绘图时奇怪的D3D9错误

时间:2017-08-02 02:10:44

标签: direct3d

所以我制作了一个程序,它连接到游戏D3D9 :: Present来画一个时钟并遇到问题,有时候,比如当我在游戏中时,颜色会显得非常它看起来很可怕。

这就是我的意思

正常:

normal clock

窃听:

enter image description here

这就是我在制作状态块之后调用的内容..

    m_Device->SetRenderState(D3DRS_VERTEXBLEND, D3DVBF_DISABLE);
    m_Device->SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, 0);
    m_Device->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, 0);
    m_Device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
    m_Device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
    m_Device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
    m_Device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
    m_Device->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
    m_Device->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
    m_Device->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
    m_Device->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
    m_Device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
    m_Device->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
    m_Device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
    m_Device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
    m_Device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
    m_Device->SetTexture(3, nullptr);
    m_Device->SetTexture(0, nullptr);
    m_Device->SetTexture(1, nullptr);
    m_Device->SetVertexShader(nullptr);
    m_Device->SetPixelShader(nullptr);
    m_Device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE); //D3DZB_TRUE
    m_Device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
    m_Device->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
    m_Device->SetRenderState(D3DRS_ZWRITEENABLE, 0);
    m_Device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); //D3DCULL_CCW
    m_Device->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
    m_Device->SetRenderState(D3DRS_FOGENABLE, 0);
    m_Device->SetRenderState(D3DRS_SPECULARENABLE, 0);
    m_Device->SetRenderState(D3DRS_STENCILENABLE, 0);
    m_Device->SetRenderState(D3DRS_CLIPPING, 0); //1
    m_Device->SetRenderState(D3DRS_LIGHTING, 0);
    m_Device->SetRenderState(D3DRS_COLORVERTEX, 1);
    m_Device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0); //1
    m_Device->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
    m_Device->SetRenderState(D3DRS_ALPHABLENDENABLE, 1);
    m_Device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); //D3DBLEND_ONE
    m_Device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); //D3DBLEND_ZERO
    m_Device->SetRenderState(D3DRS_ALPHATESTENABLE, 1);
    m_Device->SetRenderState(D3DRS_ALPHAREF, 0x08);
    m_Device->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);

我用m_Device-> DrawPrimitiveUP用D3DPT_TRIANGLEFAN绘制时钟的东西

所以我的问题是......你怎么弄清楚造成这个问题的原因是什么?我该如何解决?

1 个答案:

答案 0 :(得分:0)

通过添加此渲染状态来修复:D

    //Dis is fix for d3d9 appearing brighter??? or * 2.2 tha color orsoemthing called gammar correction
    m_Device->SetRenderState(D3DRS_SRGBWRITEENABLE, 0);