Thomas Sampson

DirectX Vs OpenGL


I thought this debate would be a good place to start for the new Games Programming section. First of all I will attempt to explain why either of these are necessary and what their roles are in the grand scheme of things.

When programmers first ventured into games programming on the desktop PC the main platform of choice was DOS. The reason for choosing DOS over a more complete operating system such as windows was that DOS gave the programmer low level access to the hardware. As the hardware specs weren’t so impressive in these times, direct access to the hardware was essential, especially when creating games with lots of graphics and perhaps 3d objects on the scene. Trying to program on top of the operating system slowed things down and the running of the operating system would often get in the way of the game code, making for slow frame rates and poor game-play, and also restricting access to the video hardware. Most “In Operating System” games would resemble windows pinball or a simple card game.

So DOS was the way forward? Well, not completely. The idea behind DOS (getting close to the hardware and maximising the potential of the graphics card) was brilliant in theory but the problem lied in compatibility. Programmers would have to write their own “drivers” for each graphics card, in many cases having to manipulate hardware registers and write manually to memory and display buffers on the graphics card. This was fine as long as the drivers worked well and the card in your PC was compatible, otherwise the game would refuse to work at all. I remember the first DOS game I played which was “Duke Nukem 3D”.

Duke Nukem 3DIn the settings dialogue there would be a list of 4 or 5 mainstream chip-sets which were supported which you could select. Overall this was not much fun for the game programmers, more time was spent on tech than it was on game-play or game design, with every game having its own “in house” game engine and graphics pipeline. At this point it is also worth mentioning that all the problems mentioned with the portability of graphics code is also applicable to audio cards, with only a select few being supported by most DOS games. Clearly something was needed to remove this diversity of code and bring some standardisation to the emerging industry. Microsoft eventually saw the market potential for gaming on the PC and came up with DirectX which is now on version 10, with its main competitor being the open standard alternative openGL (open graphics library).

The idea of both these “libraries” was to bring the hardware manufacturers and the programmers together to standardise the way things are done and provide a layer of abstraction upon the hardware. The idea is that the programmer uses a standard code library to accomplish what they want, and the calls to that library are translated into the hardware mechanisms used by the vendors of the graphics card, with the vendors making their drivers and chips conform to these libraries. This way the programmer could write efficient code and not worry about compatibility issues as it was now the responsibilty of the card manufacturers to comply with industry standards. Both Libraries are optimised to run efficiently on top of a modern operating, giving the programmer the benefit of programming in a controlled environment.

Although this post is titled “directX Vs OpenGL” I dont wish to debate this too much. The libraries are both very similar and both share a common goal (although directX is more hardware focused than openGL which strives to be a 3d rendering system which may be hardware accelerated). To me the main consideration when picking either is the platform. DirectX is striclty for windows platforms, the PC or the (direct)Xbox 360, whereas due to the open source nature of openGL it can be adapted to many hardware configurations including the PlayStation2, PlayStation3 and most Nintendo platforms. If you do wish to consider the specific comparables of each graphics API I recommend the following link.

For now I have chosen to focus my efforts on DirectX as I am informed that this is the better supported library and it is also the API I will be programming on my course next year.


Author: tomtech999

I have recently graduated with a 1st class degree in MComp Games Software Development at Sheffield Hallam University, focusing primarily on application development in C++, with experience in graphics programming, scripting languages, DVCS/VCS and web technology. In my spare time I enjoy Drumming, Reading and Snowboarding!

5 thoughts on “DirectX Vs OpenGL

  1. “Microsoft eventually saw the market potential for gaming on the PC and came up with DirectX which is now on version 10, with its main competitor being the open source alternative openGL (open graphics library).”

    OpenGL isn’t an open source project, it’s an open standard.

  2. Thanks Reaven, you are quite right, although some of the utilities for openGL are infact open source the framework is not an open source project but is indeed an open standard. Post updated!


  3. relive says : I absolutely agree with this !

  4. I’m just curious as to why you said DirectX is better supported than OpenGL, if OGL runs almost anywhere including Windows desktops, but DX is only for MSFT platforms.

  5. Hi Jules,

    I wasn’t very clear, I meant better accepted / documented. From browsing around the internet the non official support for DirectX appears much more existent and acccesible than that for openGL.

    Also I decided to go with DirectX as the applications I develop will be for the PC and not venture onto any other platforms, therefor a cross platform graphics API will not be necessary.