Search code examples
cdirectx

Is DirectX 9 or DirectX 11 supported in C?


I studied the manual for DirectX 9 and DirectX 11 and C++ was used there, I was wondering if there is DirectX support in C?

I have studied C well enough and I want to try to write a small renderer on it. I don't really like OpenGL, DirectX is much more attractive to me.


Solution

  • You can use DirectX COM interfaces from C, but the experience is generally unpleasant as it requires a lot of macros. COM interfaces map well to C++ abstract classes and single-inheritance hierarchies. It's also not well-tested as basically all users of DirectX use C++ and not C. The support that is there is basically whatever legacy behavior the MIDL compiler throws in there for C.

    You don't need to know much modern C++ to use them, so you could consider just using "C++ as a better C" for your code, and then take advantage of the more natural COM interface behavior.