Saves a mesh to a .x file.
HRESULT D3DXSaveMeshToX( LPCTSTR pFilename, LPD3DXMESH pMesh, CONST DWORD * pAdjacency, CONST D3DXMATERIAL * pMaterials, CONST D3DXEFFECTINSTANCE * pEffectInstances, DWORD NumMaterials, DWORD Format );
If the function succeeds, the return value is D3D_OK. If the function fails, the return value can be one of the following: D3DERR_INVALIDCALL.
The compiler setting also determines the function version. If Unicode is defined, the function call resolves to D3DXSaveMeshToXW. Otherwise, the function call resolves to D3DXSaveMeshToXA because ANSI strings are being used.
The default file format is binary; however, if a file is specified as both a binary and a text file, it will be saved as a text file. Regardless of the file format, you may also use the compressed format to reduce the file size.
The following is a typical code example of how to use this function.
ID3DXMesh* m_pMesh; // Mesh object to be saved to a .x file D3DXMATERIAL* m_pMaterials; // Array of material structs in the mesh DWORD m_dwNumMaterials; // Number of material structs in the mesh DWORD dwFormat = D3DXF_FILEFORMAT_BINARY; // Binary-format .x file (default) // DWORD dwFormat = D3DXF_FILEFORMAT_TEXT; // Text-format .x file // Load mesh into m_pMesh and determine values of m_pMaterials and // m_dwNumMaterials with calls to D3DXLoadMeshxxx or other D3DX functions // ... D3DXSaveMeshToX( L"outputxfilename.x", m_pMesh, NULL, m_pMaterials, NULL, m_dwNumMaterials, dwFormat );
Header: Declared in D3dx9mesh.h.