DirectX

From GPWiki
Jump to: navigation, search

So what is this wonderful DirectX thing that game programmers are always going on about? Basically, it is Microsoft's answer to game programmers' complaints that Windows is a poor platform for game development. You see, in the old days, the only thing that game programmers had to create games with in Windows was the API. Anyone who's ever tried using the API BitBlt function to make an action game can tell you that it is far too slow! (Although it is suitable for slower paced gaming.)

Enter DirectX. DirectX is a collection of DLLs that contain functions useful to game programmers, and best of all, these functions shield the programmer from issues arising from the differences in hardware from system to system. In other words, DirectX allows programmers access to fast graphics, sound, and input functions while shielding them from having to test for the capabilities of the computer on which their program is running. DirectX will assay these capabilities for you, and even if they are not present, they may be emulated for you (in many cases). You barely even have to think!

Since the release of DirectX 7.0, Visual Basic programmers have had the power to access DirectX easily. You see, DirectX now comes with it's own Visual Basic Type Libraries. A type library describes the functions contained within a DLL or group of DLLs, thereby allowing a programmer to access the capabilities contained within the DLLs. Before DirectX 7.0, we had to rely on type libraries created by a man named Patrice Scribe. These type libraries certainly did the job (and well) but DirectX 7.0 has the added boon of coming with documentation and sample programs. Now there are many resources a budding VB DirectX game programmer can draw upon.

DirectX is an API developed by Microsoft for Windows platforms. DirectX Graphics, a component of DirectX, can be considered an alternative for OpenGL and according to Microsoft much more sophisticated than its competitor. Like OpenGL this API is developed in cooperation with large graphic chip manufacturers (like ATI or nvidia).

With the advent of DirectX 9, DirectX split into two different flavors: Managed and Unmanaged. Since they are separate .dll’s, you can’t always count on user’s who have DirectX 9 to have the Managed Libraries. Unmanaged DirectX 9 is the direct descendant of DirectX 8. It has the same libraries, and works in the same general way. Unmanaged DirectX is for programming languages that do not use the .NET runtimes. Managed DirectX was invented for the .NET based languages, like Visual Basic.NET, C#.NET, etc. Managed DirectX is simpler than unmanaged, but is probably slightly slower (there are many arguments). Managed DirectX has most of the same components as unmanaged DirectX, excepting DirectShow and DirectMusic. Instead, music and videos are played with the DirectAudioVideoPlayback library.

DirectX consists of these sublibraries

Features

Feature Yes No
sound effects and music X
input X
timers X
font rendering X
windowing X
scripting X
GUI X
OpenGL X
networking X
math X
3d math X
file management  ?
threading X

The chart may be slightly inaccurate. OpenGL is a programming API similar to DirectX that accomplishes many of the same tasks as DirectX in different ways, so its inclusion in the chart is irrelevant. Also, math and file handling functions are provided by the programming languages that are calling DirectX functions, and so do not need to be included in the API. DirectX does however have some file handling for specific file types such as .X meshes and .fx shader files since these are proprietary to the DirectX API. While DirectX does not have a built in scripting language, there are many other packages out there that do allow for added scripting functionality (MonkeyScript being one of them), it does allow for windowed functionality the same way any other graphics API does.


Platforms

  • Windows
  • Xbox and Xbox 360
  • Very partially
    • UNIX (including Linux, FreeBSD, Irix, Solaris, Darwin) using wine, or Cedega (previously winex)
    • MacOS X using Darwine

Tutorials and Source Code

C++

Introduction
Direct3D
DirectInput
Source Code
External Links

VB

DirectX 7.x Tutorials

DirectDraw

DirectInput

DirectPlay

DirectSound

Direct3D

Source Code

DirectX 8.x Tutorials

Direct3D

DirectShow

Source Code

External Links

VB.NET

General
Direct3D
DirectSound
DirectInput
DirectDraw
Source Code
External Links

HLSL

General
External links

Related Weblinks