OpenGL vs. DirectX

 OpenGL              DirectX

I have been using OpenGL for about 4 years until now, it is really a very good library. But I heard a lot about DirectX and many of my students began to learn it, so I decided to do a research about it to know why they need something other than OpenGL?

In my research I read a lot of articles comparing DirectX with OpenGL, but many of them were old, also I didn’t find any article that can tell me everything I want to know. So I created this post to be an exhaustive, up-to-date comparison between OpenGL and DirectX.

I will compare current version of OpenGL which is OpenGL 3.1 with current version of DirectX (or Direct3D if we want to be more exact) which is DirectX 10.

1. Historical View


OpenGL was designed to be a cross platform 2D and 3D Graphics Library, so it doesn’t handle audio or input/output devices but it has many extensions that is made especially to handle this devices. It was developed by Silicon Graphics Incorporated in 1992.

OpenGL is no more than 250 commands which can create, manage and render any complicated scene in many fields like CAD, Virtual Reality, flight simulation and video games.

It is considered a state machine for controlling primitive objects in a scene, so usually programs written in OpenGL are small and efficient.


It was developed by Microsoft in 1995 to be an OpenGL competitive. It is a kind of API handles multimedia and specializes in games field.

It is made of a components like Direct3D (3D graphics library included DirectDraw for 2D draw), DirectMusic and DirectSound.

Nowadays there is not any product that can do all these things that DirectX can do, even though we can find an alternative for every single component.

2. Idea

DirectX was designed to be an Interface for the hardware that is provided by graphics card vendors, so it isn’t hide low details from the user.

While OpenGL is a rendering system that is accelerated by the hardware, so it is just an uniform API which leaves implementation deals with the hardware.

So we can say that DirectX started from hardware while OpenGL started from an API (or what users want), and now because of the new hardware which almost achieves all users’ dreams we can say that DirectX and OpenGL is almost the same from the idea view.

3. Extensions

OpenGL has a very important feature which is supporting extensions. Any vendor can design its hardware and make a proper extension for it so that OpenGL can use all this new hardware features. But what if two companies make two extensions that do the same thing? To solve this problem there is one standard authority for extensions named OpenGL Architecture Review Board (ARB), it chooses extensions which are really good and support new hardware and makes them standard.

On the other side Direct3D didn’t support extensions when it first made. Even worse, we know that there is at most one new version of DirectX every one year which is very long time comparing to hardware development time. So Microsoft asks vendors every year to support its new version features. That is why most of the time we see many features that are supported by Direct3D even before hardware does!

Now starting from DirectX 8, we can say that Direct3D supports pluggable software devices.

4. Portability

Direct3D was developed by Microsoft to work under Windows, and later Microsoft made some versions of it that work on XBox. There are some individual attempts (like Wine project) try to make DirectX works under other operating systems like Linux.

Microsoft not only doesn’t plane to support any Operating System other than Windows, but also puts condition about Windows version that DirectX needs, for example DirectX 10 needs Windows Vista at least to work!

While OpenGL has many Implements that work under Windows, Linux, Mac OS, OpenSolaris and PlayStation 3. And even more,  OpenGL is considered the main 3D library on iPhone, Andriod, and Symbian OS.

So when you say portability you definitely mean OpenGL.

5. Simplicity

In early versions of DirectX a lot of equivalent to simple OpenGL commands need initialization many buffers, manage them and destroy them. We can say that 90% of code size was initialization for the rest 10%. Newer DirectX versions provide an API that hides all details of buffers like initialization and destroy, so nowadays DirectX is considered as easy to use as OpenGL.

6. Performance

Microsoft said that DirectX is faster than OpenGL, and to prove that it made some tests and publish the results. SGI (Silicon Graphics Incorporated) which developed OpenGL said that OpenGL implementation which was provided by Microsoft under Windows is the problem, so it made its own implementation of OpenGL under Windows and proved that there is no problem in OpenGL structure itself to say that it is slower than DirectX, it’s only a matter of different implementations.

Something very important in performance is supporting what we called marshalling which allows optimization of GPU usage. Marshalling was supported early by OpenGL, while DirectX didn’t support it until DirectX 10 which supports some of its features because of Windows Vista.

7. Programming Languages

DirectX is based on COM technology, so DirectX can be used easily in any language that supports it like C++, Delphi or .NET

Even though OpenGL was designed to be used in C++, now there are many implementations of it that can be used almost in all programming languages like VB, Delphi, Python, Perl, Haskell, Java, .NET and even Pascal!

8. Games Field

After appearance of DirectX and OpenGL, both of them somehow tend to the largest market of Graphics, Computer Games.

In the previous years we saw a lot of games support both DirectX and OpenGL where user can choose between them from inside the game. Later on, games developers especially after appearance of DirectX 8 which introduced easy API, began to get rid of OpenGL in the interest of DirectX. The main reason was that DirectX is not only a rendering system like OpenGL it can also handle sound and input/output devices, but DirectX is more difficult to use and that is exactly what DirectX 8 came to solve. So when games developers saw that DirectX can do more than OpenGL and it is finally as easy as it, they moved to it. That is why nowadays we have many fantastic games work only on DirectX.

9. Professional Graphics

Many 3D applications like science fiction, scientific experiments and animations are made by none Graphics specialists who use OpenGL much more than DirectX, because Microsoft didn’t consider them at all when it developed DirectX to be a hardware interface specified for games. On the other side, OpenGL has many commands used only by non games developers who used OpenGL as a general 3D graphics library. So there are now many specialist programs need only OpenGL to work.

In addition to science fiction programs we see many 3D design programs especially on Mac OS (which is the favorite operating system for designers) that work on OpenGL, even that there are some programs under Windows (like 3d Max and AutoCAD) have the ability to work on both DirectX and OpenGL.

10. Web Support

Unfortunately, neither OpenGL nor DirectX works for 3D web applications. Even that some attempts are made to do that. These attempts try to render 3d scene on the server and send it to the web browser as a picture that can’t be interactive with at all. So we find ourselves forced to use browser plug-ins and make our 3D web application using java3d applet, VRML or something else.

11. Market Share

We can say that DirectX dominants Xbox market while OpenGL dominants all operating systems market except Windows. For Windows, DirectX exceeds OpenGL in games field and leaves animations field exclusively for OpenGL.


We can say that OpenGL was easier than DirectX to use, while DirectX was considered a bit faster than OpenGL. But nowadays starting from DirectX 8, DirectX partially gets rid of its difficulty and begins to attract games developers, while OpenGL proves itself and profits from stickiness of DirectX with Windows to dominants all other Operating Systems market especially Mac OS which is designers’ preferred one.

So finally we can say that the war between OpenGL and DirectX has finished, because they almost provide the same features and each one of them has its own partially dependent field.

2 Responses to “OpenGL vs. DirectX”

  1. Sufyan Mahmood Says:

    Thnx kuz, realy cleared up my mind.
    From a long time i waz confused about it./=
    Now i know where to go xD

  2. 5 mistakes Says:

    Your blog is really cool to me and your subject matter is very relevant. I was browsing around and came across something you might find interesting. I was guilty of 3 of them with my sites. “99% of site owners are guilty of these five mistakes”. You will be suprised how simple they are to fix.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: