www.quadsoftware.com
FAQ  FAQ   Search  Search   Memberlist  Memberlist   Usergroups  Usergroups
Register  ::  Log in Log in to check your private messages


Post new topic  Reply to topic
 Problem loading a texture in iStoragePlugin « View previous topic :: View next topic » 
Author Message
cmusch
PostPosted: Thu Aug 02, 2007 8:49 pm    Post subject: Problem loading a texture in iStoragePlugin Reply with quote



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
View user's profile Send private message
ALicu
PostPosted: Fri Aug 03, 2007 7:06 am    Post subject: Reply with quote



Joined: 12 Feb 2007
Posts: 1326

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
View user's profile Send private message
ALicu
PostPosted: Fri Aug 03, 2007 7:15 am    Post subject: Reply with quote



Joined: 12 Feb 2007
Posts: 1326

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
View user's profile Send private message
cmusch
PostPosted: Fri Aug 03, 2007 8:32 am    Post subject: Reply with quote



Joined: 02 Aug 2007
Posts: 33

Thanks, this indeed solved my problem. Keep up the excellent support Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Based on a template by Dustin Baccetti
Powered by phpBB © 2001, 2005 phpBB Group