简体   繁体   中英

OpenGL vs Direct3D?

I am a Java programmer who has a fair amount of experience with Swing, which I have used for 2D game programming. I am interested writing 3D games and am not sure which API to use - OpenGL or Direct3D.

  • I don't care about portability or backwards compatibility or any of that. I am programming as a hobby on a Windows machine.
  • The greatest factor in my choice is this: which API gives me the best performance-to-speed ratio?
  • However, I also want the API which is fairly well documented on the Internet. I don't want to waste time groping in the dark.

Other less major factors

  • Which one has "cleaner" code? Which one is more object-oriented?
  • I understand that OpenGL is usually used with C++. I would prefer to use C#. Which of the two is easier to use in C#?

Both are usable from C#, thanks to OpenTK and SharpDX respectively. Of the two, SharpDX is the youngest but also the most actively developed.

Both offer excellent performance if used properly. I don't think it is possible to prove that either is faster than the other.

Of course, OpenGL has much wider compatibility across platforms, but if all you care about is Windows, then that is not an issue.

Direct3D is somewhat more object-oriented than OpenGL; it's a COM API while OpenGL is a C API. Neither leads to pretty code, they're very low-level APIs after all. If object-oriented and clean is what you want, you should look into some higher-level utility than these APIs, for instance XNA/MonoGame.

I'm not a partisan, but everything you're saying suggests you'd probably be more comfortable - and arguably more productive - with the Microsoft solution.

You didn't mention your OS or environment. But let's assume you have a reasonably fast PC (with hardware acceleration), lots of RAM, lots of disk ... and, ideally, Windows 7/64-bit.

You can download Visual Studio for free here:

You can download the DirectX SDK here:

And you can find tons of useful tutorials, documentation and sample code everywhere.

Good luck - and have fun!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM