3
\$\begingroup\$

I am now trying to abstract my rendering pipeline, and I've been able to abstract OpenGL fairly easily. But now I have ran into a rather ugly problem with Directx.

Most of my knowledge about Dx9, 10, and 11 makes use of effect files. Something that openGL distinctly lacks. I know that this file does not have to be used. However, by the way all of DX's documentation had been written, it seems like it is required and there is no way around it.

Can anyone give me a lead here?

\$\endgroup\$
1

1 Answer 1

5
\$\begingroup\$

FXC or D3DXCompileShader or D3DCompile to compile basic HLSL vertex/pixel/... shaders (single entry point, just like GLSL).

Then create shaders from the generated shader blobs using API functions such as CreatePixelShader (D3D9) or CreatePixelShader (D3D10/11). Then apply these shaders with SetPixelShader (D3D9) or PSSetShader (D3D10,11).

To transfer uniform data to shaders, since you want to deal with both D3D9 and 10/11, I'd suggest getting used to mapping uniform values manually by appending code like : register(c0) (D3D9 uniform values) and : register(b0) (for D3D10/11 uniform blocks). A documentation page on shader constants could help make sense of this.

This tutorial shows how to compile non-effect shaders from file in D3D11.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .