Upcoming Events
Unite 2010
11/10 - 11/12 @ Montréal, Canada

GDC China
12/5 - 12/7 @ Shanghai, China

Asia Game Show 2010
12/24 - 12/27  

GDC 2011
2/28 - 3/4 @ San Francisco, CA

More events...
Quick Stats
64 people currently visiting GDNet.
2406 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!
Link to us Events 4 Gamers
Intel sponsors gamedev.net search:

Contents
 Introduction
 The Basic Blit
 Final Word

 Printable version
 Discuss this article

Final Word

DirectDraw programmers looking to migrate to the new API will have hopefully gained some useful insight into the inner workings of Direct3D.

While it isn't hard to rewrite the ID3DXSprite routines, there is a lot of mundane work to do so you might as well take advantage of my mundane work. The discussed techniques are incorporated in the demo program.

Further Reading

  1. DirectX 8.0 Documentation: DirectX Graphics, Microsoft Corp, October 4, 2000.
    1. Introduction: Getting Started.
    2. Using: Surfaces, Textures, and Vertex Formats.
    3. Understanding: Transformation and Lighting Engine.
    4. Programming Tips: Performance Optimizations.
    5. Tutorials: Vertices, Matrices, and Texture Maps.
    6. Samples: Billboard and PointSprites.
    7. C/C++ Reference.
  2. Robert Dunlop, DirectX 8 Graphics FAQ, X-Zone/MVPs, July 12, 2001.
  3. Robert Dunlop, A Simple Blit Function for DirectX 8, X-Zone/MVPs, July 12, 2001.
  4. George Geczy, 2D Programming in a 3D World: Developing a 2D Game Engine Using DirectX8 Direct3D, Gamasutra, June 29, 2001. (A printable version is available.)
  5. Herbert Wolverson, Using Direct3D For 2D Tile Rendering, GameDev.net, accessed July 17, 2001.

Acknowledgements

Thanks to Mario Knezovic (mario.knezovic@bonespark.com) for helping me with this article. Mario provided the inclusive-exclusive explanation to this problem. (I thought Microsoft's rectangles were incorrectly implemented but this is not the case.)


About the Demo

Download d3dblit.zip to obtain the demo (and source code) for this article.

The demo draws six sprites to show off the blitting techniques discussed in this article. These images are arranged like so

123
456

The sprites are

  1. Microsoft's blit: ID3DXSprite.
  2. Dunlop's blit (BlitX): no extensions.
  3. Dunlop's blit (BlitX): extend all sides by 0.5.
  4. The new blitter (Blit): extend right and bottom by 1.
  5. The new blitter (Blit): scaling (-1, 2.4).
  6. The new blitter (Blit): rotation and colour modulation.

Compare sprites 1 to 4 with the original bitmap in sprites.bmp.

Tip: use [Alt] + [Print Screen] to copy the active window and then paste the image into any Windows paint program. Tools like zoom make it easier to compare images.

Sprites 5 and 6 show off the effects available in Blit: scaling, rotation, and colour modulation.