Original Post
ive got this function to load the mesh and i cant seem to make it show up on screen , if this code is in main then it works fine , some problem with the parameters thats not making it work right , SetMaterial and the rest is in RenderMesh(); in main... Code: #include "Globals.h" HRESULT LoadD3DMeshNew( IDirect3DDevice9* g_pDirect3DDevice, DWORD dwNumMaterials, LPD3DXMESH pMesh, D3DMATERIAL9* pMeshMaterials, LPDIRECT3DTEXTURE9* pMeshTextures ) { LPD3DXBUFFER pD3DXMtrlBuffer; if( FAILED( D3DXLoadMeshFromX( "airplane 2.x", D3DXMESH_SYSTEMMEM, g_pDirect3DDevice, NULL, &pD3DXMtrlBuffer, NULL, &dwNumMaterials, &pMesh ) ) ) { MessageBox(NULL, "Could not find tiger.x","Meshes.exe", MB_OK); return E_FAIL; } else { // MessageBox(NULL, "Loaded tiger.x","Meshes.exe", MB_OK); } // We need to extract the material properties and texture names from the // pD3DXMtrlBuffer D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*)pD3DXMtrlBuffer->GetBufferPointer(); pMeshMaterials = new D3DMATERIAL9[dwNumMaterials]; pMeshTextures = new LPDIRECT3DTEXTURE9[dwNumMaterials]; char buf[64]; sprintf(buf , "%s %d" , "dwNumMaterials is" , dwNumMaterials); // MessageBox(NULL, buf,buf, MB_OK); for( DWORD i=0; i = d3dxMaterials.MatD3D; // Set the ambient color for the material (D3DX does not do this) pMeshMaterials.Ambient = pMeshMaterials.Diffuse; // Create the texture if( FAILED( D3DXCreateTextureFromFile( g_pDirect3DDevice, d3dxMaterials.pTextureFilename, &pMeshTextures ) ) ) { pMeshTextures = NULL; } } // Done with the material buffer pD3DXMtrlBuffer->Release(); return S_OK; }