Original Post
Hi,
I have 25 Mesh Objects in my little Engine. The problem ist that it takes 10 Seconds to load or process or whatever these Mesh Files on my Athlon 2600. I load them directly from a ressource. Is this normal or can I do something to speedup the method. Here is the code:
bool D3DObjectClass::loadMesh(int mesh, LPDIRECT3DDEVICE8 *g_pD3DDevice)
{
m_pD3DDevice = g_pD3DDevice;
LPD3DXBUFFER pMaterialsBuffer = NULL;
LPD3DXMESH pMesh = NULL;
if(FAILED(D3DXLoadMeshFromXResource(
GetModuleHandle(NULL),
MAKEINTRESOURCE(mesh),
"Mesh",
D3DXMESH_SYSTEMMEM,
(*m_pD3DDevice),
NULL,
&pMaterialsBuffer,
&m_dwNumMaterials,
&pMesh)))
{
m_pMesh = NULL;
m_pMeshMaterials = NULL;
m_pMeshTextures = NULL;
return false;
}
D3DXMATERIAL* matMaterials = (D3DXMATERIAL*)pMaterialsBuffer->GetBufferPointer();
//Create two arrays. One to hold the materials and only to hold the textures
m_pMeshMaterials = new D3DMATERIAL8[m_dwNumMaterials];
m_pMeshTextures = new LPDIRECT3DTEXTURE8[m_dwNumMaterials];
for(DWORD m = 0; m < m_dwNumMaterials; m++)
{
// Copy the material
m_pMeshMaterials[m] = matMaterials[m].MatD3D;
// Set the ambient color for the material (D3DX does not do this)
m_pMeshMaterials[m].Ambient = m_pMeshMaterials[m].Diffuse;
cube_colour=0x10FFFFFF;
// Create the texture
if(matMaterials[m].pTextureFilename != NULL)
{
texture = ASTEROID_bmp; }
if(FAILED(D3DXCreateTextureFromResource((*m_pD3DDevice),NULL,
MAKEINTRESOURCE(texture),
&m_pMeshTextures[m])))
{
m_pMeshTextures[m] = NULL;
}
texture = false;
}
//We''ve finished with the material buffer, so release it
SafeRelease(pMaterialsBuffer);
//Make sure that the normals are setup for our mesh
pMesh->CloneMeshFVF(D3DXMESH_MANAGED, MESH_D3DFVF_CUSTOMVERTEX, (*m_pD3DDevice), &m_pMesh);
SafeRelease(pMesh);
D3DXComputeNormals(m_pMesh, NULL);
rot_x = 0;
rot_y = 0;
rot_z = 0;
return true;
}