user1299784 user1299784 - 8 days ago 10
C# Question

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#?


Answer

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.

Comments