I have a strange problem using Irrlicht (OpenGL) on Windows with multitexturing.
I am trying to display a simple cube with 2 textures. At first it worked ok, but later I added a second cube without any texture... and a strange thing occured: when the second cube is displayed, the first cube does not use the second texture anymore!
See the following example:
Code: Select all
//load 2 texture (image is a standard image with no alpha channel, image2 is a semi transparent image with alpha)
video::ITexture* image = _driver->getTexture("image.jpg");
video::ITexture* image2 = _driver->getTexture("alpha-image.png");
//create a cube and assign 2 textures
IMeshSceneNode* myNode = _smgr->addCubeSceneNode(500);
myNode->setMaterialType(irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL);
myNode->setMaterialTexture(0, image);
myNode->setMaterialTexture(1, image2);
//create a dummy cube
IMeshSceneNode* myNode2 = _smgr -> addCubeSceneNode(10); //IF I COMMENT THIS LINE THE FIRST CUBE IS OK
// STANDARD RUN LOOP
while(_device->run())
{
if(_input.IsExit())
{
_device->closeDevice();
}
_driver->beginScene(true, true, SColor(255,0,0,0));
_smgr->drawAll();
_driver->endScene();
}
IMeshSceneNode* myNode2 = _smgr -> addCubeSceneNode(10);
The display is as expected (picture on top) and with the line the alpha image is not used anymore (bottom image)
Any idea? Is there something wrong in my code? Is it expected?
Thanks for any help!