英文:
Is DirectX 9 or DirectX 11 supported in C?
问题
我研究了DirectX 9和DirectX 11的手册,那里使用了C++,我想知道C中是否支持DirectX?
我已经学习了足够的C,想尝试在其上编写一个小型渲染器。我不太喜欢OpenGL,DirectX对我更有吸引力。
英文:
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.
答案1
得分: 2
你可以从C中使用DirectX COM接口,但这通常会很不愉快,因为它需要大量的宏。 COM接口与C++抽象类和单继承层次结构很好地映射。 它的支持也不够完善,因为基本上所有DirectX的用户都使用C++而不是C。 那里的支持基本上是MIDL编译器为C添加的遗留行为。
你不需要了解太多现代C++来使用它们,因此你可以考虑只将“C++作为更好的C”用于你的代码,然后利用更自然的COM接口行为。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论