DirectX 9或DirectX 11在C中支持吗?

huangapple go评论66阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年7月4日 19:59:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76612402.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定