| Author |
Message
|
| cmusch |
Posted: Thu Aug 02, 2007 8:49 pm Post subject: Problem loading a texture in iStoragePlugin |
|
|
Joined: 02 Aug 2007 Posts: 33
|
Hi!
I get a horrible crash when trying to assign a texture to my surface description. My code:
| Code: |
iStorage * tex_storage = g_storage_man->GetStorageFromPath(toUnicode(tex_path).c_str());
assert(tex_storage->GetNodesNo() && "Storage has no texture");
iTexture * tex = (iTexture*)tex_storage->ExtractNode(cur_mesh->getTextureName()[0].c_str());
if (!tex) msgBox(std::string("Couldn't find tex ") + cur_mesh->getTextureName()[0]);
t_error ret = tex->Load(); // <---- This line triggers the crash
|
The directory contains dxt5 dds textures. Is there anything basically wrong with this way of loading a texture, or is the problem elsewhere?
Loading the mesh without texture, just positions and normals, works fine.
The error message is something like "The value of ESP was not saved properly across a function call"... |
|
| Back to top |
|
 |
| ALicu |
Posted: Fri Aug 03, 2007 7:06 am Post subject: |
|
|
Joined: 12 Feb 2007 Posts: 1259
|
Hmm, this looks like the public SDK interface is not matching the internal interface used by the application (hence the ESP register problem). I will have to do a simple plugin to test that code and I will get back to you with a solution.
Regards,
Adrian L. |
|
| Back to top |
|
 |
| ALicu |
Posted: Fri Aug 03, 2007 7:15 am Post subject: |
|
|
Joined: 12 Feb 2007 Posts: 1259
|
After looking a little more at your code, I think I may found the problem.
When you call iStorage::ExtractNode you actually get the image interface (iImage) and not a texture (iTexture). So your cast is invalid.
The code should like this:
| Code: |
iStorage * tex_storage = g_storage_man->GetStorageFromPath(toUnicode(tex_path).c_str());
assert(tex_storage->GetNodesNo() && "Storage has no image");
// Create a texture with a default name, without storage.
iTexture* tex = (iTexture*)g_sdk_root->NewNode(C_NODE_FACTORY_TEXTURE, NULL, NULL, NULL);
// Set the image from the storage as the source of the texture.
tex->SetSourceImage(cur_mesh->getTextureName()[0].c_str(), tex_storage);
// Now load the image and fill the texture.
tex->Load();
|
I hope this code works for you.
Adrian L. |
|
| Back to top |
|
 |
| cmusch |
Posted: Fri Aug 03, 2007 8:32 am Post subject: |
|
|
Joined: 02 Aug 2007 Posts: 33
|
Thanks, this indeed solved my problem. Keep up the excellent support  |
|
| Back to top |
|
 |
|
|