3D Game Engine Programming


Book's Contents and Errata

On this website you will find all bugfixes and updates for this book which is published in the "Game Development Series" edited by André LaMothe and published by Course PTR (former Premier Press): Course PTR.

Unfortunately it seems that some file on the accompanying CD-ROM are broken or corrupted. Furthermore there had been no compiled static or dynamic libraries provided which are developed throughout the book. As a result you cannot just run each chapter's demo but you have to build the libraries first. I apologize for any inconvinece caused.

On this website you will find all the answers and solutions that will make the demos run. Additionally there is a small update to the code for chapter 6 to be able to compile the font functions with the latest DirectX SDK because its interfaces were changes from DirectX 9.0a to 9.0b.

If you have any comments or questions feel free to drop me a message by mail Stefan.Zerbst@zfx.info or come to visit the online game devloping learning place Gameversity where I also offer courses on DirectX and game programming.


 
Check out at Amazon: click me

Contents of this Website

1. Download Update Files
2. How to Compile the Code from the accompanying CD-ROM
3. Changes to the ID3DXFont Interfaces (chapter 6)
4. Download the Milkshape .ms3d to CBF converter (chapter 8)
5. Known issues
6. Editor Crash on Level Saving NEW
7. Reported Bugs NEW


Last Update: 9th September 2004 (Download Chap13 Data, Know Issues)


1. Download Update Files (for the first print of the book)

Note that this paragraph does only apply for readers who own the first print of the book.

The following update download contains a replacement cpp file for chapter 6 as well as a new level file for use in chapter 14 and chapter 15. The source code file of chapter 6 had been updated to be compilable with the changed D3DXFont interface of the DirectX SDK version 9.0b or greater.

Download ZIP file (600 kb)

The second download contains a new model file alien.cbf and again the new level file. Both are meant for chapter 15 because the files on the CD-ROM seem to be broken. You can just copy the original chapter 15 directory from the CD-ROM and then copy the contents of this download to replace the ones copied from the CD-ROM. The download is fairly big because it also contains the compiled static libraries and dynamic libraries you wil lneed in this chapter. So you can just compile and start it after the update.

Download ZIP file (1.6 MB)


The third download contains the test data used in the space partitioning demo in Chapter 13 because it seems that the file is also broken on the CD-ROM. Just copy this one into the Chapter 13 folder to replace the original one.
br> Download ZIP file (130 kb)


2. How to Compile the Code from the accompanying CD-ROM


3. Changes to the D3DXFont interface in DirectX 9.0b (for the first print of the book)

Due to a change in the DirectX SDK with the summer update you need to change the method ZFXD3D::CreateFont introduced in chapter 6. You can find this function in the "ZFXD3D_main.cpp" file. Now you don't need to build a Win32 font object but you can create a Direct3DX font directly. Change the function to look like the one printed below and compare the SDK documentation for the parameters if you don't find them selx-explanatory. Since the SDK documentation is not very comprehensive in this part compare the Win32 API function CreateFont() and its parameters to the D3DXCreateFont() function because it uses more or less the same parameters. You can also compare the samples coming with the DirectX SDK because most of them are using the D3DXFont object to display text.

HRESULT ZFXD3D::CreateFont(const char *chType, int nWeight, bool bItalic,
                           bool bUnderline, bool bStrike, DWORD dwSize, 
                           UINT *pID) 
{
   HRESULT hr;
   HDC hDC;
   int nHeight;

   if (!pID) return ZFX_INVALIDPARAM;

   hDC = GetDC( NULL );
   nHeight = -MulDiv(dwSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
   ReleaseDC(NULL, hDC);

   m_pFont = (LPD3DXFONT*)realloc(m_pFont, sizeof(LPD3DXFONT)*(m_nNumFonts+1));

   // build D3DX font from GDI font
   hr = D3DXCreateFont( m_pDevice, // Direct3D device
                        nHeight, nHeight/2, // font height and width
                        nWeight, // thickness, 0=default, 700=bold
                        1, // mipmap levels
                        bItalic, // italic style
                        DEFAULT_CHARSET, // character set
                        OUT_DEFAULT_PRECIS, // precision
                        DEFAULT_QUALITY, // quality
                        DEFAULT_PITCH | FF_DONTCARE, // pitch and family
                        "Arial", // font face (=font type)
                        &m_pFont[m_nNumFonts]); // address for new font

   if (SUCCEEDED(hr)) 
   {
      (*pID) = m_nNumFonts;
      m_nNumFonts++;
      return ZFX_OK;
   }
   else return ZFX_FAIL;
} // CreateFont
/*----------------------------------------------------------------*/

Then the ID3DXFont::Begin and ID3DXFont::End functions had been removed and an additional parameter introduced for the rendering call. Here is the slightly changed ZFXD3D::DrawText function:

HRESULT ZFXD3D::DrawText( UINT nID, int x, int y, UCHAR r, 
                          UCHAR g, UCHAR b, char *ch, ...) 
{
   RECT rc = { x, y, 0, 0 };
   char cch[1024];
   char *pArgs;

   // put variables into the string
   pArgs = (char*) &ch + sizeof(ch);
   vsprintf(cch, ch, pArgs);

   if (nID >= m_nNumFonts) return ZFX_INVALIDPARAM;

   // calculate actual size of the text
   m_pFont[nID]->DrawText(NULL, cch, -1, &rc, DT_SINGLELINE | DT_CALCRECT, 0);

   // now draw the text 
   m_pFont[nID]->DrawText(NULL, cch, -1, &rc, DT_SINGLELINE, 
   D3DCOLOR_ARGB(255,r,g,b));

   return ZFX_OK;
} // DrawText
/*----------------------------------------------------------------*/


4. Download the Milkshape .ms3d to CBF Converter

- Converter Download: click Author: Oliver Düvel (mail)

5. Known issues (for the first print of the book)

- Chapter 7: Demos 2, 3, 4, and 6 do not work with DirectX SDK summer update 2004
  It seems that using the latest video drivers solves this issue
- Chapter 13: Does not display anything with DirectX SDK summer update 2004


6. Editor Crash on Level Saving

While going back to the files supplied on the CD-ROM I found that there is indeed a problem while saving a level. There seems to be an old ZFXRenderDevice.h header used, causing a function call to the skin manager to hit the wrong function implementation because the library features one function that the old header does not know about.

To solve this editor-saving-crash simply do the following:

7. Reported Bugs