Sometimes it is nice to start with a clean sheet of paper. While I can make jokes about Microsoft starting over eight times when it comes to DirectX, the latest version of DirectX is Microsoft’s freshest start since DrawPrimitive came into style. DirectX 8 (DX8) really shows its maturity. Many operations have been simplified and streamlined, and it is now embarrassingly easy to access advanced functions. As an example, I used to write short OpenGL applications in under 500 lines. My pre-DX8 Direct3D initialization code was around 1000 lines. Now, with DX8, my OpenGL and Direct3D applications look almost identical. Since DX8 is so different, I won’t spend a lot of time talking about what has changed. Instead, I will discuss what the API looks like now, and how you can take advantage of it in no time. The DX8 Foundation consists of 6 APIs: DirectX Graphics (which includes Direct3D and the D3DX library), DirectX Audio (which includes DirectSound and DirectMusic), DirectInput, DirectPlay, DirectSetup, and DirectShow. DX8 is huge, so I won’t cover it all here. This article will get you started programming graphics and video using DX8. I do not know if there is going to be an updated version of DirectX Media. DirectShow was formerly included in DirectX Media, but now it is part of the base DirectX runtime. The advantage to this is that now developers can take advantage of this API without having to install a separate runtime. Direct3D Retained Mode was part of DirectX Media, but the D3DX library mostly replaces this API. I suspect that DX transforms, another component of DirectX Media, has remained unchanged, and can be used from the old DirectX Media 6.1 SDK. DirectX GraphicsPerhaps the most glaring change to DirectX is the lack of DirectDraw. DirectDraw is dead, replaced completely by Direct3D. Direct3D is super-streamlined, and contains many new features. No longer do you have to enumerate everything under the sun. Direct3D consists of only 12 interfaces. The inheritance graph is very simple: One of the coolest features is the addition of a shader language. Microsoft’s new shader language looks more like assembly language than it looks like Renderman or Quake 3’s shader language. However, the concepts are all the same. Direct3D comes with a high level library called D3DX. The D3DX library is very slick, containing APIs to create everything from sprites, to fonts, to textures. Using D3DX is an easy way to jump-start your development. Matrix operations are very clean (especially with D3DX), and it is far easier to work with than OpenGL. There are many other similarities with OpenGL:
Many of these similarities appeared in earlier versions of DirectX, but with the new simplifications of DX8, it is very apparent as to how similar Direct3D and OpenGL now are. 2D programming is not dead even with the removal of DirectDraw. DX8 does have a sprite interface in its D3DX library. However, the preferred way to do 2D graphics is with simple textures. Since chroma keying has been removed, the only way to do transparency is with alpha blending. You can probably tell that I am quickly becoming a fan of this API. I used to be an OpenGL die hard, but with all the improvements, there is little reason not to use Direct3D in your games. We’ll write some code shortly that will let you hitting the ground running. DirectX Graphics is just plain awesome. The rest of DX8 looks old in comparison. After working with DX8 for a few days, you will wish other DX8 APIs worked like it. DirectShowDirectShow is Microsoft’s API for everything video. Anything to do with VCR’s, digital camcorders, and DVD players can be found here. It is no surprise that playback of video files also falls under this category, and game developers can now use this API with ease to add FMV to their games. There are some new things added to DirectShow, but few are of interest to game developers. Support for European PAL video has been enhanced (meaning that it works now). Filters can be added and removed while a filter graph is running. Native support for Microsoft’s streaming format, ASF, has been added as well. However, even though DirectShow has many improvements, it remains the buggiest portion of DX8 due to its complexity. Since playback of video is the primary reason why a game developer would use DirectShow, we’ll do some code that does just that a little bit later. |
|||||||||||||||||||||||||