/* cMesh.h */
class cMesh
{
// *snip*
LPDIRECT3DTEXTURE9* MeshTextures;
};
/* cMesh.cpp */
bool cMesh::Load(string FileName)
{
// *snip*
string Path = "Data\\Tex\\Tiny_skin.dds";
HR = D3DXCreateTextureFromFile(D3D->GetD3DDevice(), Path.c_str(), &MeshTextures);
// *snip*
};
DXCreateTextureFromFile + Pointers
Hey, I need some help read the comments for more info
The HR returns a D3DERR_INVALIDCALL - Invalid call so I think there is something wrong with the parameters I passed? Not really sure. But yeah I can't seem to quite figure what's up but I presume it's something to do with the pointer situation which is getting me really confused... I debugged and stepped through step by step and some interesting things occured:
std::c_str returned 0x00c62f80 <Bad Ptr> const char *
&MeshTextures 0x00000000 IDirect3DTexture9 * *
So my Path is possibly screwing it up? Which is leading the Mesh to still equal NULL. Hmm... I'm not quite sure [confused] so yeah any help would be very much appreciated [smile]
-Jemburula
For extra reference I thought I'd just post a chunk of the cMesh::Load just in case you needed extra info
// Copy the data from MaterialBuffer into MeshMaterials and MeshTextures for(DWORD i = 0; i < this->NumMaterials; ++i) { this->MeshMaterials = Materials.MatD3D; this->MeshMaterials.Ambient = this->MeshMaterials.Diffuse; // Create the texture if it exists this->MeshTextures = NULL; if(Materials.pTextureFilename) { Path = "Data\\Tex\\Tiny_skin.dds";// + Materials.pTextureFilename; LPCSTR FinalPath = Path.c_str(); HR = D3DXCreateTextureFromFile(D3D->GetD3DDevice(), FinalPath, &MeshTextures); if(FAILED(HR)) { D3D->WriteConsole("Failed: cMesh::Load texture with file " + Path); Error("Failed: cMesh::Load->" + Path + ": " + (string)DXGetErrorString9(HR) + " - " + (string)DXGetErrorDescription9(HR)); PostQuitMessage(0); return false; }; }; };
Your MeshTextures is a pointer to LPDIRECT3DTEXTURE9... so you need to initialise it with MeshTextures = new LPDIRECT3DTEXTURE9[numTextures];
Only then can you do &MeshTextures. I don't know if you snipped this out or what, but if the array is not allocated, in debug mode you would pass a zero pointer to the D3DXCreateTextureFromFile, which would make it fail.
I don't think there's anything wrong with the string usage.
(edit)
Now that you posted your init, this is the fault: this->MeshTextures = NULL; You're indicing into a null pointer array.
Only then can you do &MeshTextures. I don't know if you snipped this out or what, but if the array is not allocated, in debug mode you would pass a zero pointer to the D3DXCreateTextureFromFile, which would make it fail.
I don't think there's anything wrong with the string usage.
(edit)
Now that you posted your init, this is the fault: this->MeshTextures = NULL; You're indicing into a null pointer array.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement