ID3DXSprite Example

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • ID3DXSprite Example

      First of all, I must compliment the author. This is one of my favorite game programming books and has been an invaluable tool to brush up on my game-coding techniques while trying to change jobs from the broadcast industry to the gaming industry.

      There was 1 thing I felt was lacking: a simple, full-featured example of a 2D application using ID3DXSprite. I must admit that this book has more coverage of this interface than any other book or resource I have found; however, it still was not enough to create a simple application that displays a static bitmap as a background to the screen that behaves properly in both windowed and fullscreen modes. Given that the documentation Microsoft provides for this interface is virtually non-existent (and it provides no examples of using it either), it would be nice to have a short walk-through on how to use it (since it is recommended to not use DirectDraw for future development).

      After about a week of digging for samples and documentation that is non-existant, and another week of trial and error, I was finally able to get it to do what I wanted (basically, create a viewing screen for a simple Tetris-clone). I can't speak for anyone else, but I feel that such an example would be invaluable in a future edition of the book.
    • If you feel it would be useful - I'm sure you'd make lots of people happy if you posted the example on this site.
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • I'm not sure where you would like it posted, so I'll post a link here:

      olympianstudios.net/~zhowland/files/DXTest2_code.zip

      It is based on the Empty Project example that comes with the DirectX SDK. The application simply loads the background.bmp file and displays it as a background image. It starts in windowed-mode and you can switch back and forth between windowed and fullscreen mode using ATL-ENTER.

      The notable code for supporting the ID3DXSprite interface is found in the OnResetDevice, OnFrameRender, OnLostDevice, and OnDestroyDevice functions.

      As a side note, the documentation for ID3DXSprite indicates that when you lose a device, you do not need to recreate the interface (simply call ID3DXSprite::OnLostDevice and ID3DXSprite::OnResetDevice for those actions). However, when I tried to use that procedure the image would not display when I switched screen modes.