Introduction
Designing and implementing 3D applications have never been easier than it is nowadays. There are a couple of great technologies making many architects confused about which one is the best or which one to choose for the given project. The choice is not easy – there is ol` OpenGL (with it`s new edition – CsGL – made especially for C# language), there is also well known DirectX, but there are some very new technologies and concepts as well, like WPF or XNA. Each of them offers great functionality for modeling advanced 3D enviroment. Microsoft is the owner of 3 of them (all but CsGL). It raises obvious question – why the hell Microsoft is involved into developing three competitive technologies?
The answer is simple – each of them is quite different. Lately I have been involved in a major project that required many different graphical functionalities to be implemented. These included both 3D world modelling and 2D drawing. I spent many hours on distinguishing these technologies and I would like to share my knowledge. This article presents a brief description of each of them. It also compares them and recommends the best usage of each of them.
OpenGL (CsGL)
OpenGL is the oldest of all these technologies. In many years it was the most popular technology as well. Many great old games (like Quake3 or Wolfenstein: Enemy Territory) have been implemented in OpenGL.
OpenGL was originaly designed for C/C++ languages. As C# differs in many ways from those (eg. C# programmers don`t use pointers almost at all) there was a need for creating a special wrapper for OpenGL to adapt it for C# language. This wrapper is already finished (all functionality has been implemented and all known bugs have been resolved) and it is called CsGL. I have tried it and it works as expected. Great job.
Probably the biggest OpenGL advantage is the fact that this technology is very old. As a result there are a lot of different tutorials, articles, examples and other stuff in the Web. You can always quickly and easily find what you are looking for.
CsGL has a one major drawback though. It is sticked to procedural programming model. This won`t be a big deal for older software developers, however many younger developers are accustomed to OOP (object oriented programming) model. They didn`t use procedural programming model almost at all. This is why they won`t be too happy to start using CsGL and even if they will, they will mostly produce code of a bad quality. It is difficult to switch from OOP to procedural programming for younger people.
DirectX
DirectX technology is Microsoft`s response to OpenGL. The first version was relased in 1995 and until the version 8.0 relased in 2000 it was always considered to be second-best to OpenGL. It contained many bugs and it was quite difficult to use in many cases. However the newest versions (DirectX 9, 10 and 11) are stable and reasonable relases that offers tons of functionality. They are fully integrated with Windows (XP, Vista and Windows 7) as well as with the .NET Framework. They are properly documented and there are many examples available in the Web.
The biggest advantage of DirectX over OpenGL is that the newest versions use OOP model instead of prodecural programming model. This is a major facilitation for younger developers.
It is hard to point out any significant disadvantages of DirectX. Probably the biggest issue is the fact that this is lower-level technology compared to WPF or XNA. This means that you must have greater skills and knowledge to develop applications in DirectX. But on the other hand this also means that you have more possibilities to write efficient and smart solutions.
WPF
WPF stands for Windows Presentation Foundation. It is newest Microsoft`s technology for designing user interfaces. It is somewhat the next generation of WinForms, although it uses many concepts known from ASP.NET (like styling or code-behind files). Microsoft says that this is revolutionary technology and it really is. The main reason for this is the fact that WinForms and all concurrent technologies are using GDI+ behind the scenes. WPF is the first technology that passes by this layer and uses DirectX directly. That`s why it is so fast and efficient. It is a very powerfull technology as well. It not only exposes standard functionality for designing typical user interfaces (consisting of some forms, buttons, etc.), but it also allows advanced 2D drawing as well as 3D world modelling. As such this technology is a concurrent technology to both WinForms and DirectX.
What is worth knowhing about this technology is that this is higher-level technology compared to DirectX or CsGL. As such it exposes less functionality but simplier things may be accomplished in a much faster manner and they do not require developers to have so strong knowledge and skills.
Personally I recommend WPF to every typical desktop application (where WinForms used to be complied in the past). However this choice is not so obvious regarding 3D world modelling.
XNA
XNA is a Microsoft`s technology that facilitates games development for Windows, Zune (digital media players) and Xbox 360 platforms. First version was announced in 2004. The aim of this technology is to simplify computer game development as much as possible. Microsoft publishes special tool for XNA development – XNA Game Studio. This tool is somehow similar to Visual Studio. XNA is strongly oriented for game development and no other kind of applications are intended to be designed using this technology.
Putting them all together
The following table summarizes some key features of these technologies:
|
|
CsGL
|
DirectX
|
WPF
|
XNA
|
|
Easy to learn
|
1
|
2
|
3
|
2
|
|
High-level technology
|
1
|
1
|
3
|
2
|
|
Fast development
|
1
|
1
|
3
|
3
|
|
Application`s performance
|
3
|
3
|
1
|
3
|
Conclusion
Generally speaking WPF is a great technology for modeling simple 3D worlds, that do not require many objects to be created within, nor any extra effects (like shaders). It allows such applications to be developed in extremely fast way. In all other cases WPF might not be the best solution.
CsGL on the other hand is quite old technology and is sticked to procedural programming model. This is why I do not recommend it for any type of application.
For more advanced 3D applications definitely either DirectX or XNA would be the best choice. It quite hard to distinguish them. XNA seems to be a bit easier and higher level technology, although DirectX is much more popular. As a result there are plenty of articles and tutorials concerning DirectX in the Web. Currently Microsoft puts great deal of effort to developing both of them and none of them is to become obsolete in the nearest future.