Saturday, October 27, 2007

OpenGL or DirectX..?


As far as I know, there are two major APIs (Application Programming Interface) for graphics and multimedia programming. Microsoft's DirectX and open source OpenGL.
OpenGL is the industrial standard for graphic programming. It is based on the open source ideas and therefore I think it is "Platform Independent". OpenGL can be applied to Windows, Linux, Unix, Mac and so on. In contrast, DirectX is developed by Microsoft for its famous Windows operating systems.

Before I attend the M.Sc (Digital Media Technology) course in NTU, I thought that OpenGL was far more difficult to program than DirectX. And most of the graphic hardware won't support OpenGL. I thought like that because all graphic hardware (graphic cards) that I used before had DirectX compatible drivers with them but sometimes they did not contain good drivers for OpenGL. Therefore, I thought that OpenGL has less support by hardware than DirectX. However, as I am attending Digital Media courses in NTU, our lecturers use OpenGL very widely and I know that OpenGL is used for many graphics purposes and it is on the same level of DirectX.
But I think the reason for DirectX is more widely used than OpenGL is that OpenGL supports only 3D graphics and DirectX technology has many components in it. May be wrong, I think that OpenGL is best for only 3D graphics and even not very good for 2D graphics and animation techniques. We need to do refinements for 3D to 2D changing to create 2D graphics and animations with OpenGL. But that's what I think.

On the other hand, DirectX has many components in it.
DirectDraw for 2D graphics and Direct3D for 3D graphics
DirectSound for creating sounds
DirectSound3D for 3D interactive sound effects for games
DirectMusic for creating background musics for applications (such as MIDI)
DirectInput for programming various input devices especially for games
DirectPlay that supports programmers for hardware independent network game creation
DirectShow for streaming media playback
and many more. Therefore, it can be said that DirectX has more functionalities than OpenGL. (Can you find a game without DirectX support.?)

But the good thing for OpenGL that I think is OpenGL is more stable than DirectX and it is "open source". DirectX is changing so rapidly than OpenGL. (The latest version as I know is DirectX 10). Since Windows operating systems are widely used all over the world, DirectX technologies also becomes de-fecto standard for game and multimedia programming world. But I think today's graphic hardware contained in many computer systems also support both DirectX and OpenGL APIs.

In my opinion, OpenGL is more widely used for scientific visualizations and simulations tasks. Microsoft's DirectX is used widely in gaming and multimedia industry. DirectX technology is more complicate to install because of its many components. OpenGL is easy and compact to install compare to DirectX.

So, which one is better? I don't know and I can't decide..! As digital media technical person and as digital media programmer, I think I should know and understand both OpenGL and DirectX technologies to enter into the multimedia world.

3 comments:

  1. Nice blog.
    Have some comments. ;)
    DirectDraw is removed since DX8. For 2D purposes, check out this article: http://www.myanmaritpros.com/group/gameprogramming/forum/topic/show?id=1445004%3ATopic%3A14376

    There's also OpenAL for audio purposes.

    ReplyDelete
  2. DirectX 8, 9, 10, etc. still contain the DX7 DirectDraw interface ("DD7 interface"). Its name is DIRECTDRAW7, however the DX9/10 SDKs don't adequately document the DD7 interface and it's difficult to download the DX7/8 SDKs which provide documentation. Also DirectDraw is deprecated, its functionality having been absorbed into Direct3D, largely in the Plain Surface and Overlay Surface support.

    This article, 2D in Direct3D using Textured Quads, seems to be a reasonable starting point for transitioning from DirectDraw to Direct3D.

    Also, Microsoft's XNA site has samples of 2D apps. See Vector Rumble for example. You'll also find a link to their 2D Graphics examples on the right.

    Recommended starting points for 2D DX9 dev: D3DXSprite and 2D Blits in DirectX 9.

    ReplyDelete
  3. Hi Eric,
    Sorry about my wrong meaning of comment.
    I meant DD was deprecated by M$ for future release of DX. Pardon my English. :)
    And yes, there are still many games and frameworks out there that use DD (eg. PopCap Framework) because of it's availability on various PCs.

    Thanks

    ReplyDelete