Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DirectX or OpenGL [closed]

If you were writing the next 3d graphics intensive application in C# (like a 3d modelling and animation software), which one would be a better choice?

If we consider C# as platform independent, then OpenGL seems tempting, but what about the performance, etc?

Since the used language is C#, the performance is pretty crucial to consider.

Edit: You can also consider SlimDX and TAO, OpenTK, csGL, etc too.

like image 648
Joan Venge Avatar asked Feb 02 '09 20:02

Joan Venge


People also ask

What is the difference between OpenGL and directdraw/3d?

Well first we have to clarify that OpenGL is not the same type of API as DirectX. It is strictly graphics, whereas DirectX can handle sound networking input and graphics. So the question really is OpenGL vs DirectDraw/3d. DirectDraw/3d (on its simplest level) sets up an environment that is similar to what VGA programming used to be.

Should I use OpenGL or DirectX for game development?

If you want to adress cross platform features use OpenGl, if Windows is your platform for development go with DirectX. Think there is no wrong answer. Functionality i similar. DirectX is less dependant on external libraries, for OpenGl you need wrappers such as Glew, Glut or something like that.

What is open OpenGL and how does it work?

OpenGL is a cross-language as well as cross-platform of API (application programming interface) which works for the rendering of 2D and 3D vector graphics and interact with GPU (graphics processing unit) for achieving hardware-accelerated rendering. It was developed by the Khronos group as an open-source that was free to work with.

What is DirectX?

DirectX. Definition: It is an open-source cross-platform application of interface programming which works on rendering of vector graphics of 2d and 3d graphics. DirectX is a collection APIs which re using for many different types of multimedia platform as well as game programming. Developer


1 Answers

Performance in managed code, with respect to the graphics subsystem, is not bad. SlimDX pays a slightly penalty over completely native code on each call into DirectX, but it is by no means severe. The actual penalty depends on the call -- a call into DrawPrimitive will be vastly more expensive overall than a call to SetRenderState, so percentage-wise you end up losing a lot more on the SetRenderState calls. SlimDX incorporates a tuned math library that generally performs very well, although you have to be a bit careful with it. Profiling, even with a junker tool like NProf, highlights this stuff very quickly so it's not difficult to fix.

Overall, if we consider generic, completely optimal C++ and C# code doing rendering via D3D, the C# version is probably within 10-15% of the C++ version. That's hard to achieve though; consider how much time you're saving by working in C# which you can apply to higher level graphics optimizations that you probably simply wouldn't have time for if you had to build the entire thing in C++. And even if you managed to get that extra 10% in C++, it'd promptly shrink to 5% within a few months, when a new round of hardware tears through your application code faster than ever. I know what I'd pick -- which is why I wrote SlimDX to begin with.

OpenTK is subject to similar performance characteristics, with the caveat that their math library is rather slow in places. This is an implementation bug that I've discussed with them, and will hopefully be fixed before too long.

like image 168
Promit Avatar answered Oct 08 '22 18:10

Promit