Game Engineering 2 Assignment 8


1. Create a Texture Builder that can convert images in most common image formats to DDS images.

2. Apply textures to meshes.

Create a Texture Builder

To convert an image to a DDS image, there are 3 things we need to do:

1) Get the information about the image using D3DXGetImageInfoFromFile function.

The reason we do this is we need to know what kind of texture it is. An image could be a texture, a cube texture or a volume texture and each kind of texture has its own create function.

If we dig further we will find that Direct3D support the following image file formats: BMP, JPG, TGA, PNG, DDS, PPM, DIB, HDR, PFM.

2) Create a texture from the image file

To create a texture we called D3DXCreateTextureFromFileEx function.

To create a cube texture we called D3DXCreateCubeTextureFromFileEx function.

To create a volume texture we called D3DXCreateVolumeTextureFromFileEx function.

3) Save the texture to a file

To save the texture as a DDS file, we called D3DXSaveTextureToFile(path, D3DXIFF_DDS, pTexture, NULL).

Texture Coodinates

The texture coordinates in Direct3D 9 are defined like this:


Here is a screenshot of my program:


Here is a PIX capture showing the texture I used:


Here is the definition of my plane that using this texture:


Time Estimates

  • Reading – 2 hours
  • Coding – 4 hours
  • Write up – 2 hours
  • Total – 8 hours

Download Executable

Leave a Reply