Microsoft DirectX 9.0

Step 3: Unloading a Mesh Object

After any Microsoft?DirectX?program finishes, it needs to deallocate any DirectX objects that it used and invalidate the pointers to them. The mesh objects used in this sample also need to be deallocated. When it receives a WM_DESTROY message, the Meshes sample project calls Cleanup, an application-defined function, to handle this.

The following code fragment deletes the material list.

if( g_pMeshMaterials )
    delete[] g_pMeshMaterials;

The following code fragment deallocates each individual texture that was loaded and then deletes the texture list.

if( g_pMeshTextures )
    for( DWORD i = 0; i < g_dwNumMaterials; i++ )
        if( g_pMeshTextures[i] )
delete[] g_pMeshTextures;

The following code fragment deallocates the mesh object.

Delete the mesh object
if( g_pMesh )

This tutorial has shown you how to load and render meshes. This is the last tutorial in this section. To see how a typical Microsoft Direct3D?application is written, see Samples.

© 2002 Microsoft Corporation. All rights reserved.