I'm reading the "Introduction to 3D game programming with DirectX11" (Frank Luna) and i'm having problems with lighting. I have this error: Effect version is unrecognized. This runtime supports fx_5_0 to fx_5_0. When i use the D3DX11CreateEffectFromMemory function i have that error and an exception (this->mFX was nullptr) Can you help me? Thanks EDIT: I have no D3DCompileFromFile

std::ifstream fin("Ligthing.fx", std::ios::binary);  
        fin.seekg(0, std::ios_base::end);
        int size = (int)fin.tellg();
        fin.seekg(0, std::ios_base::beg);
        std::vector<char> compiledShader(size);

        fin.read(&compiledShader[0], size);
        hr=D3DX11CreateEffectFromMemory(&compiledShader[0], size, //ERROR IS HERE
            0, device, &mFX);

        if (FAILED(hr)) {
            MessageBox(0, L"err", 0, 0);

You should use the latest version of Effects for Direct3D 11 which is available on GitHub. It includes D3DX11CreateEffectFromFile which is for creating an effect from a compiled effect file (aka fxo), and D3DX11CompileEffectFromFile which is for creating an effect from a shader that is first compiled at runtime (aka fx).

See this post for some history of Effects for Direct3D 11

The older version of Effects for Direct3D 11 in the legacy DirectX SDK was a bit purist about forcing the developer to deal with the binary file loading and interop with D3DCompile. I just added the missing utility functions to the library instead when I moved it to GitHub.

Be sure to read Is Effects 11 deprecated? and What's the difference between an .fx and .hlsl file anyhow? as well for the status of FX11.

  • \$\begingroup\$ Thanks for the help, i have the latest version of Effects already and my code is working, but i didn't know about the .fxo thing, so thank you a lot \$\endgroup\$ – Emanuele Mar 1 '17 at 9:32

So the problem was in the "Lighting.fx". Had to compile it, so it became "Lighting.fxo". I didn't compile it by myself, i used the one provided by the book i'm reading which is "Intruduction to 3d game porgramming with DirectX 11" (Frank Luna)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.