D3DXLoadMeshFromXResource function

Loads a mesh from a resource.

Syntax

HRESULT D3DXLoadMeshFromXResource(
  _In_  HMODULE           Module,
  _In_  LPCSTR            Name,
  _In_  LPCSTR            Type,
  _In_  DWORD             Options,
  _In_  LPDIRECT3DDEVICE9 pD3DDevice,
  _Out_ LPD3DXBUFFER      *ppAdjacency,
  _Out_ LPD3DXBUFFER      *ppMaterials,
  _Out_ LPD3DXBUFFER      *ppEffectInstances,
  _Out_ DWORD             *pNumMaterials,
  _Out_ LPD3DXMESH        *ppMesh
);

Parameters

Module [in]

Type: HMODULE

Handle to the module where the resource is located, or NULL for the module associated with the image the operating system used to create the current process. See remarks.

Name [in]

Type: LPCSTR

Pointer to a string that specifies the resource to create the mesh from. See remarks.

Type [in]

Type: LPCSTR

Pointer to a string that specifies the resource type. See remarks.

Options [in]

Type: DWORD

Combination of one or more flags from the D3DXMESH enumeration that specify creation options for the mesh.

pD3DDevice [in]

Type: LPDIRECT3DDEVICE9

Pointer to an IDirect3DDevice9 interface, the device object associated with the mesh.

ppAdjacency [out]

Type: LPD3DXBUFFER*

Address of a pointer to an ID3DXBuffer interface. When the method returns, this parameter is filled with an array of three DWORDs per face that specify the three neighbors for each face in the mesh.

ppMaterials [out]

Type: LPD3DXBUFFER*

Address of a pointer to an ID3DXBuffer interface. When this method returns, this parameter is filled with an array of D3DXMATERIAL structures, containing information saved in the DirectX file.

ppEffectInstances [out]

Type: LPD3DXBUFFER*

Pointer to a buffer containing an array of effect instances, one per attribute group in the returned mesh. An effect instance is a particular instance of state information used to initialize an effect. See D3DXEFFECTINSTANCE. For more information about accessing the buffer, see ID3DXBuffer.

pNumMaterials [out]

Type: DWORD*

Pointer to the number of D3DXMATERIAL structures in the ppMaterials array, when the method returns.

ppMesh [out]

Type: LPD3DXMESH*

Address of a pointer to an ID3DXMesh interface, representing the loaded mesh.

Return value

Type: HRESULT

If the function succeeds, the return value is D3D_OK. If the function fails, the return value can be one of the following values: D3DERR_INVALIDCALL, E_OUTOFMEMORY.

Remarks

See FindResource to find out more about the Module, Name and Type parameters.

All the meshes in the file will be collapsed into one output mesh. If the file contains a frame hierarchy, all the transformations will be applied to the mesh.

For mesh files that do not contain effect instance information, default effect instances will be generated from the material information in the .x file. A default effect instance will have default values that correspond to the members of the D3DMATERIAL9 structure.

The default texture name is also filled in, but is handled differently. The name will be Texture0@Name, which corresponds to an effect variable by the name of "Texture0" with an annotation called "Name." This will contain the string file name for the texture.

Requirements

Requirement Value
Header
D3DX9Mesh.h
Library
D3dx9.lib

See also

Mesh Functions

D3DXEFFECTDEFAULT

D3DXEFFECTINSTANCE