Page 1 of 1

Texture problem

Posted: Wed May 30, 2007 8:45 pm
by kendric
Hi, I was working on a project based off of the irrilicht\newton tutorial and I had it compiling and running just fine. I started a set of modifications and when i try to run now I get an Access violation writing location 0x81d15a3a when doing this:

IAnimatedMesh *mesh = smgr->getMesh("data/smallcube.3ds");
ISceneNode *node= smgr->addAnimatedMeshSceneNode(mesh);
node->setMaterialTexture(0, driver->getTexture("data/crate.jpg"));

When i step into setMaterialTexture, the violation happens on the line accented below:

void setMaterialTexture(u32 textureLayer, video::ITexture* texture)
{
if (textureLayer>= video::MATERIAL_MAX_TEXTURES)
return;

for (u32 i=0; i<getMaterialCount(); ++i)********
getMaterial(i).Textures[textureLayer] = texture;
}

I have worked in java for many years and am comming back to c++
The function pointer is on that line, i hit step into and it throws the access violation. From looking on the net, access violation most commonly is caused by trying to use a null object. The only thing I can gather is the getMaterialCount function is causing it. The material shows as created in the console output. Any ideas as to what might have happened?

Posted: Wed May 30, 2007 9:53 pm
by kendric
Apparently this was caused by me having a animated mesh with no texture elsewhere in the code.