用于新的 Windows 游戏项目的 OpenGL 或 Direct3D?或者是其他东西?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39092/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
OpenGL or Direct3D for a new Windows game project? Or something else?
提问by Antti Kissaniemi
I'm starting a hobby game project on Windows that will make heavy use of 3D graphics effects. It will most likely be written in C++.
我正在 Windows 上启动一个业余爱好游戏项目,该项目将大量使用 3D 图形效果。它很可能是用 C++ 编写的。
Should I use OpenGL or Direct3D for my graphics backend? Why?
我应该为我的图形后端使用 OpenGL 还是 Direct3D?为什么?
Or should I use a ready-made graphics engine such as OGRE 3D? Which one?
还是应该使用现成的图形引擎,例如OGRE 3D?哪一个?
Some "how to get started" links would be useful. (On either technology, or both.)
一些“如何开始”链接会很有用。(在任何一种技术上,或两者兼而有之。)
Edit- Yes I really meant Direct3D, not DirectX, thanks to graham.reedsfor clarification
编辑- 是的,我的意思是 Direct3D,而不是 DirectX,感谢graham.reeds的澄清
Edit- Mihai Lazarpointed out that I could also use a graphics engine such OGRE 3D. Edited the question to reflect this alternative.
编辑- Mihai Lazar指出我也可以使用像 OGRE 3D 这样的图形引擎。编辑问题以反映此替代方案。
回答by Eugene Yokota
Start with OpenGL because there are good textbooks and other online references on it. Once you get the hang of writing 3D game, you would be able to make the judgment for yourself.
从 OpenGL 开始,因为它有很好的教科书和其他在线参考资料。一旦掌握了编写 3D 游戏的窍门,您就可以自己做出判断了。
Finishing a game, even if it's really stupid and simple just to get you going, is more important than picking the right library. With glut, you can get some 3D object to show up on your screen in a day. Start with NeHe's tutorials.
完成一个游戏,即使它真的很愚蠢和简单只是为了让你开始,比选择正确的图书馆更重要。使用glut,您可以在一天内让一些 3D 对象显示在您的屏幕上。从NeHe的教程开始。
回答by lancekt
If you're willing to consider C#, take a good look at XNA. For hobby projects, assuming what you want is to actually get a game up and running instead of tinkering with complex API code, I cannot recommend it highly enough. It is increasingly mature, well-documented, and, compared to D3D/OpenGL, very quick and easy to use. As a bonus, with a $100/year Creators Club membership, you can even use it to develop games for the Xbox 360.
如果您愿意考虑 C#,请仔细查看 XNA。对于业余爱好项目,假设您想要的是真正启动并运行游戏而不是修补复杂的 API 代码,我怎么推荐都不够。它越来越成熟,文档齐全,并且与 D3D/OpenGL 相比,非常快速且易于使用。作为奖励,拥有 100 美元/年的 Creators Club 会员资格,您甚至可以用它来为 Xbox 360 开发游戏。
回答by Mihai Lazar
You could also base your work on ogrethey provide the abstraction themselves and they have really nice tools. Since this is a projects that's been around for over 6 years I think. The base library is not really for beginners since you need to know a bit about software design, but I found a lot of people that have written games using it.
你也可以将你的工作建立在ogre 上,他们自己提供抽象,而且他们有非常好的工具。由于这是一个已经存在 6 年以上的项目,我认为。基础库并不适合初学者,因为您需要对软件设计有所了解,但我发现很多人使用它编写游戏。
It would be safer and quicker than learning the heavier stuff since it's already been abstracted. Plus after a couple of month you'll be talking 3D jargon anyways. There is also a book to get you started with Ogre, I think it's kinda old by now but a starting point anyways.
因为它已经被抽象了,所以它比学习更重的东西更安全、更快。再加上几个月后,您无论如何都会谈论 3D 行话。还有一本书可以让你开始使用 Ogre,我认为它现在有点旧,但无论如何都是一个起点。
回答by graham.reeds
You must remember that DirectX is a collection of technologies - Input, Audio and Graphics. However to most people DX is synonymous with the renderer.
您必须记住 DirectX 是一组技术 - 输入、音频和图形。然而,对于大多数人来说,DX 是渲染器的同义词。
In my opinion D3D (or DirectGraphics) has not really been that hard since DX8. I have not tried DX9 or DX10.
在我看来,D3D(或 DirectGraphics)从 DX8 开始就没有那么难了。我没有试过 DX9 或 DX10。
Bernard is right - try to abstract as much as possible. Try to keep DX or OGL calls outside your object classes.
伯纳德是对的——尽量抽象。尝试将 DX 或 OGL 调用保留在对象类之外。
回答by José Carlos Gil
I have no previous OpenGL, DirectX or videogame experience and i have made have an open source race videogamewith Ogre3d. Is a very good framework to start in videogames: well done code, plenty of docsand info in the net and very good starting tutorials.
我以前没有 OpenGL、DirectX 或视频游戏经验,我已经使用Ogre3d制作了一个开源竞赛视频游戏。是一个非常好的电子游戏入门框架:做得很好的代码,网络上的大量文档和信息以及非常好的入门教程。
The rendering engine is DirectX/OpenGl agnostic, you can later select to render your game with OpenGL or DirectX (withouth changes in your code)
渲染引擎与 DirectX/OpenGl 无关,您可以稍后选择使用 OpenGL 或 DirectX 渲染您的游戏(无需更改代码)
回答by Mark Ingram
I did my dissertation at uni on a comparison of OpenGL vs Direct3D. The real benefits of Direct3D are that it has a regular release schedule - it's always being updated to take advantage of the latest advances in graphics hardware. How long has it taken between the OpenGL 2.0 and 3.0 releases? Also, a lot of work has been done in extensions for OpenGL, which means only some rendering will work on some cards.
我在 uni 完成了一篇关于 OpenGL 与 Direct3D 比较的论文。Direct3D 的真正好处是它有一个定期的发布时间表——它总是被更新以利用图形硬件的最新进展。OpenGL 2.0 和 3.0 发布之间需要多长时间?此外,在 OpenGL 的扩展方面已经做了很多工作,这意味着只有一些渲染可以在某些卡上工作。
Having said that, OpenGL will be easier to start programming with. As Direct3D is based heavily in COM, it has a steep learning curve.
话虽如此,OpenGL 将更容易开始编程。由于 Direct3D 大量基于 COM,因此它具有陡峭的学习曲线。
If it were me, I would be choosing DirectX over OpenGL. That's at the cost of non-platform independance.
如果是我,我会选择 DirectX 而不是 OpenGL。这是以非平台独立性为代价的。
回答by Bernard
Best thing to do would be to abstract over your renderer as much as possible, to make porting to the other technology as painless as possible.
最好的办法是尽可能地抽象你的渲染器,尽可能轻松地移植到其他技术。
回答by Bernard
For the situation that you describe, I would recommend Direct3D.
对于您描述的情况,我会推荐 Direct3D。
The primary reason to use Direct3D instead of OpenGL is that often video card vendors only do a good job on the OpenGL drivers for their "high end" cards.
使用 Direct3D 而不是 OpenGL 的主要原因是视频卡供应商通常只在他们的“高端”卡的 OpenGL 驱动程序上做得很好。
The low end game type cards tend to get poor and generally buggy drivers, causing problems on your end user's machines.
低端游戏类型卡的驱动程序往往很差且通常有问题,从而导致最终用户的机器出现问题。
If portability is important, then that would be a big reason to look at OpenGL or Ogre instead.
如果可移植性很重要,那么这将是改用 OpenGL 或 Ogre 的一个重要原因。
But if you never plan to port, then focus on Direct3D since it is a more widely stable platform with better IHV driver support.
但是,如果您从不打算移植,那么请关注 Direct3D,因为它是一个更广泛稳定的平台,具有更好的 IHV 驱动程序支持。
回答by dreamlax
It is my understanding that in Direct3D you must handle all resource allocation and management yourself, whereas the OpenGL specification leaves this to the driver/implementation rather than the application.
我的理解是,在 Direct3D 中,您必须自己处理所有资源分配和管理,而 OpenGL 规范将这留给驱动程序/实现而不是应用程序。
This allows Direct3D developers to use the best allocation and management methods suitable to the application, but is also extra work.
这允许 Direct3D 开发人员使用适合应用程序的最佳分配和管理方法,但也是额外的工作。
I have done the typical "Hello World" applications in each, and I prefer OpenGL over Direct3D, but that is just my opinion. You should try out both, spend a day or two learning and playing around with each, and decide for yourself.
我已经完成了典型的“Hello World”应用程序,我更喜欢 OpenGL 而不是 Direct3D,但这只是我的意见。您应该同时尝试两者,花一两天的时间学习和玩耍,然后自己决定。
回答by Perry
To answer this question well requires more information about you:
要很好地回答这个问题需要更多关于你的信息:
- what is your programming ability?
- 你的编程能力是什么?
If it's high, I would probably start with Ogre (the best strictly rendering open source engine, IMHO) or another open source game engine, such as Delta3D, if you want additional features (sound, physics, etc.) that a game engine brings.
如果它很高,我可能会从 Ogre(最好的严格渲染开源引擎,恕我直言)或其他开源游戏引擎开始,例如 Delta3D,如果您想要游戏引擎带来的附加功能(声音、物理等) .
If you don't want to go with an engine, I would go with Direct3D, because it's being updated much quicker than OpenGL. I don't want to get into all the issues, but version 3.0 of OpenGL was announced during SIGGRAPH and most in the community were very disappointed with it. Direct3D puts you in a much better position to take advantage of shaders and other uses of the programmable pipeline.
如果您不想使用引擎,我会使用 Direct3D,因为它的更新速度比 OpenGL 快得多。我不想讨论所有的问题,但 OpenGL 3.0 版是在 SIGGRAPH 期间宣布的,社区中的大多数人对它非常失望。Direct3D 使您能够更好地利用着色器和可编程管道的其他用途。
If your programming ability is not too high, and you are doing this to learn programming, I would start with OpenGL, because it is easier to learn and there are more resources on the web (see http://nehe.gamedev.netfor example).
如果你的编程能力不太高的,你这样做是为了学习编程,我会用OpenGL开始,因为它更容易学习,也有在网络上更多的资源(见http://nehe.gamedev.net为例子)。