zhangbaochong
zhangbaochong

Reputation: 170

How to compile shader with newest Effect Framework?

I usually use the Microsoft DirectX SDK (June 2010) which is deprecated. I download vs2015 which includes newest directx sdk and latest version FX11 on github. I don't know how to compile shader now.

Upvotes: 1

Views: 374

Answers (1)

zhangbaochong
zhangbaochong

Reputation: 170

I know, it is so easy, just one function D3DX11CompileEffectFromFile is OK.

//compile shader
    ID3DBlob* errorBlob;
    DWORD shaderFlags = D3DCOMPILE_ENABLE_STRICTNESS;

#if defined _DEBUG || defined DEBUG
    shaderFlags = D3DCOMPILE_DEBUG;
#endif

    hr = D3DX11CompileEffectFromFile(L"color.fx", nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, shaderFlags,
        0, m_pd3dDevice, &m_pFx, &errorBlob);
    if (FAILED(hr))
    {
        MessageBox(nullptr, (LPCWSTR)errorBlob->GetBufferPointer(), L"error", MB_OK);
        return hr;
    }

    m_pTechnique = m_pFx->GetTechniqueByName("ColorTech");
    m_pFxWorldViewProj = m_pFx->GetVariableByName("gWorldViewProj")->AsMatrix();

Upvotes: 3

Related Questions