Saturday 28 May 2011

OpenGL vs DirectX

OpenGL really is quite incredible. It has the honor of being used for nearly every 3D environment, or at least a variation of it is used for nearly every 3D environment. Its libraries are used across phones, games consoles, TVs, computers and hundreds of other devices. Despite this incredible success, is it really the best tool for 3D today in applications?

DirectX is what Microsoft likes to sell to the world. It is used in Windows, Windows Phone and XBOX. DirectX has frequently been the choice of games developers working on Windows because it has a wide set of libraries and integrates incredibly well into Windows. It is currently being used to render Windows Presentation Foundation (WPF) applications built with the .Net framework and these are frequently faster than their WinForms counterparts.

However, both DirectX and OpenGL have advantages and disadvantages. The problem with both is that when you are using the other on a platform that they both exist on (basically Windows) there is no reason not to use either of them. DirectX is just as good as OpenGL for most tasks and vice verse. However, there is a reason to use OpenGL over DirectX: its lightweight.

I hadn't really dabbled much in OpenGL programming with C++ before, however I realized that my compiler already had all the tools that I needed to get started, and I did. However, if I wanted to get started with DirectX development on my computer, I would have to download the enormous DirectX SDK, and I don't really want to have to do that.

Not only is OpenGL already there, but it isn't difficult either. Creating windows with C++ is hardly hard work - it can be done in about 30 lines of code and with a bit more work you can add OpenGL support. My IDE on my laptop, Dev-C++, comes with an OpenGL sample of a triangle spinning round and this is just 191 lines of code. What's more is that even an OpenGL beginner like me can read the code, it is all just basic functions and numbers - no complex pointers or anything.

OpenGL also has the advantage that it can be used in just about any programming language, even JavaScript now, whereas DirectX has a very limited portfolio.

I can't really say that I am into 3D graphics programming, however it is very interesting, and I am sure that I will consider it more in the future.

No comments:

Post a Comment