theCNG27
theCNG27

Reputation: 425

DirectX Compile Shader from Memory?

Using shaders compiled from files like this works:

    D3DX11CompileFromFile(filename, NULL, NULL, "main", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, NULL, 
                   &vertexShaderBuffer, &errorMessage, NULL);

But if I replace the above line with this one:

D3DX11CompileFromMemory(vs, strlen(vs), NULL, NULL, NULL, "main", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, NULL, 
                   &vertexShaderBuffer, &errorMessage, NULL);

While vs is a char* of the shader file (if I print vs out using std::cout, it prints correctly).

It just crashes at that line...

What am I doing wrong?

Upvotes: 0

Views: 3632

Answers (1)

galop1n
galop1n

Reputation: 8824

D3DX APIs are deprecated, you should use the D3DCompile APIs instead from D3DCompiler.h. Mostly the same things with D3DX11 replaced by D3D so transition is simple.

Edit your message with at least a callstack or output log because wihtout more information, it is hard to be more specific on an answer.

Upvotes: 2

Related Questions