Problems when deleting textures... [Update: possible bug?]

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.

Problems when deleting textures... [Update: possible bug?]

Postby Rytz » Thu Jan 31, 2008 10:25 am

I am doing a manual loop through the cache of textures because I need to keep some textures loaded in memory since they are used frequently. I'm not having any problems removing textures this way. See below:

Code: Select all
void Video::ClearTextures(){

    // clear all textures except reusables...
    for (long l = irrVDriver->getTextureCount() - 1; l >= 0; l--)
        if (irrVDriver->getTextureByIndex(l)->getName().find("#default") == -1 &&

//irrVDriver->getTextureByIndex(l)->getName().find("particlered.bmp") == -1 &&
//irrVDriver->getTextureByIndex(l)->getName().find("particlewhite.bmp") == -1 &&
//irrVDriver->getTextureByIndex(l)->getName().find("fireball.bmp") == -1 &&

            irrVDriver->getTextureByIndex(l)->getName().find("./media/images/loading.bmp") == -1 &&
            irrVDriver->getTextureByIndex(l)->getName().find("./media/fonts") == -1)
            irrVDriver->removeTexture(irrVDriver->getTextureByIndex(l));
}


After removing all of the other textures (saving the ones included in the IF statement), I have the correct count and names of the textures that I wanted to stay in the cache.

However, the next time my program attemps a ISceneManager::drawAll(), it crashes.

The 3 lines that are commented in the code above are the textures that seem to be the culprits. If I force those 3 specific textures to be left in the cache (uncomment the lines), my program does not crash.

I take this as either I have a memory leak or something is trying to reference those 3 textures. But I don't understand how it can be the latter if I successfully removed the textures from the cache and I know 100% that nothing else is trying to reference those textures. The getReferenceCount() of those 3 textures gives me a count of 1. I don't have a seperate pointer variables for the textures either.

Any thoughts would be greatly appreciated.

Sorry if I was vague at all. It's 4:30am and I'm pretty tired :).

Edit:
I was going to ask also if there was something I needed to do after removing individual textures? I'm assuming Irrlicht auto-updates everything that needs to be updated when it comes to referencing textures and such.
Last edited by Rytz on Sat Feb 02, 2008 9:32 am, edited 1 time in total.
Image
User avatar
Rytz
 
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA

Re: Problems when deleting textures...

Postby rogerborg » Thu Jan 31, 2008 10:45 am

Rytz wrote:But I don't understand how it can be the latter if I successfully removed the textures from the cache and I know 100% that nothing else is trying to reference those textures.


It seems that the compiler disagrees with you. What does your debugger tell you? Where's the crash, what's the call stack?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
User avatar
rogerborg
Admin
 
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh

Postby vitek » Thu Jan 31, 2008 3:49 pm

But I don't understand how it can be the latter if I successfully removed the textures from the cache and I know 100% that nothing else is trying to reference those textures.


Are you 100% sure that no scene node materials reference any of the textures that you removed from the cache?

The getReferenceCount() of those 3 textures gives me a count of 1.


The material doesn't grab() and drop() the textures that you apply, so the reference count is not a reliable way to determine if a texture is used or not.

I was going to ask also if there was something I needed to do after removing individual textures?


After you've removed the textures, you shouldn't need to do anything. You should probably be making sure that the textures are not in use by any scene node before removing them.

I'm assuming Irrlicht auto-updates everything that needs to be updated when it comes to referencing textures and such.


You know what they say about assume. Don't do it, it makes an ass of u and me. To put it bluntly, you are totally wrong. Irrlicht expects you to make sure the textures are not in use or are grabbed when they are removed from the cache. This is mentioned in the documentation.

Travis
User avatar
vitek
Bug Slayer
 
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Postby vitek » Thu Jan 31, 2008 3:50 pm

You might find this useful. It allows you to get an array of all of the textures in use by the current scene graph.

Code: Select all
u32
ISceneNode_getUsedTextures (scene::ISceneNode* node, core::array<video::ITexture*>& a)
{
  u32 count = 0;

  for (u32 m = 0; m < node->getMaterialCount (); ++m)
  {
    const video::SMaterial& material = node->getMaterial (m);

    for (u32 n = 0; n < video::MATERIAL_MAX_TEXTURES; ++n)
    {
        video::ITexture* texture = material.getTexture (n);
        if (!texture)
            break; // if texture n is not set, assume n+1 is not

        // make sure texture is not in array before we try to put
        // it in
        if (a.linear_search (texture) < 0) {
            a.push_back (texture);

            // increment count of textures added
            count += 1;
        }
    }
  }

  // now recurse on children...
  core::list<scene::ISceneNode*>::ConstIterator begin = node->getChildren().begin();
  core::list<scene::ISceneNode*>::ConstIterator end   = node->getChildren().end();

  for (/**/; begin != end; ++begin)
    count += ISceneNode_getUsedTextures(*begin, a);

  return count;
}

u32
ISceneManager_getUsedTextures(scene::ISceneManager* smgr, core::array<video::ITexture*>& a)
{
    return ISceneNode_getUsedTextures (smgr->getRootSceneNode (), a);
}


Travis
User avatar
vitek
Bug Slayer
 
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Postby Rytz » Thu Jan 31, 2008 8:12 pm

Thanks for the replies. When I get on my laptop later I'll post some more info about the problem.
Image
User avatar
Rytz
 
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA

Postby Rytz » Fri Feb 01, 2008 10:51 am

Ok so something else that I just noticed while trying to debug this problem is that it only crashes with OpenGL.

It involves the textures that are loaded in the following nodes:

Code: Select all
    // ---------------
    // Light Nodes
    // ---------------
   // LIGHT 1: (small fireball) & fly circle animator
   ercvScene_Gateway->nodeSmallFireballLight =
      ptrClient->ptrVideo->dvWindow->getSceneManager()->addLightSceneNode(0, core::vector3df(0,0,0),
      video::SColorf(0.5f, 1.0f, 0.5f, 0.0f), 100);
    nodeFlyCircleAnim = ptrClient->ptrVideo->dvWindow->getSceneManager()->createFlyCircleAnimator(core::vector3df(-70, 130, 45), 100.0f, 0.005f, core::vector3df(.2, 1, 1));
   ercvScene_Gateway->nodeSmallFireballLight->addAnimator(nodeFlyCircleAnim);
    nodeFlyCircleAnim->drop(); nodeFlyCircleAnim = 0;

   // attach billboard to the light
   ercvScene_Gateway->nodeSmallLightBill = ptrClient->ptrVideo->dvWindow->getSceneManager()->
        addBillboardSceneNode(ercvScene_Gateway->nodeSmallFireballLight, core::dimension2d<f32>(60, 60));
    ercvScene_Gateway->nodeSmallLightBill->setMaterialTexture(0, ptrClient->ptrVideo->irrVDriver->getTexture("./media/images/particlered.bmp"));
   ercvScene_Gateway->nodeSmallLightBill->setMaterialFlag(video::EMF_LIGHTING, false);
   ercvScene_Gateway->nodeSmallLightBill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);

   // LIGHT 2: (large fireball) & fly circle animator...
   ercvScene_Gateway->nodeLargeFireballLight =
      ptrClient->ptrVideo->dvWindow->getSceneManager()->addLightSceneNode(0, core::vector3df(0, 0, 0),
      video::SColorf(1.0f, 0.2f, 0.2f, 0.0f), 200.0f);

    nodeFlyCircleAnim = ptrClient->ptrVideo->dvWindow->getSceneManager()->createFlyCircleAnimator(core::vector3df(-70, 130, 45), 100.0f, 0.00075f, core::vector3df(.2, 1, .1));
    ercvScene_Gateway->nodeLargeFireballLight->addAnimator(nodeFlyCircleAnim);
    nodeFlyCircleAnim->drop(); nodeFlyCircleAnim = 0;

   // attach billboard to light
   ercvScene_Gateway->nodeLargeLightBill = ptrClient->ptrVideo->dvWindow->getSceneManager()->
        addBillboardSceneNode(ercvScene_Gateway->nodeLargeFireballLight, core::dimension2d<f32>(120, 120));
    ercvScene_Gateway->nodeLargeLightBill->setMaterialTexture(0, ptrClient->ptrVideo->irrVDriver->getTexture("./media/images/particlewhite.bmp"));
   ercvScene_Gateway->nodeLargeLightBill->setMaterialFlag(video::EMF_LIGHTING, false);
   ercvScene_Gateway->nodeLargeLightBill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);

    // ---------------
    // Particles
    // ---------------
   // add particle system
   ercvScene_Gateway->nodeParticleSystem =
      ptrClient->ptrVideo->dvWindow->getSceneManager()->addParticleSystemSceneNode(false, ercvScene_Gateway->nodeLargeFireballLight);
    ercvScene_Gateway->nodeParticleSystem->setMaterialTexture(0, ptrClient->ptrVideo->irrVDriver->getTexture("./media/images/fireball.bmp"));
   ercvScene_Gateway->nodeParticleSystem->setParticleSize(core::dimension2d<f32>(30.0f, 40.0f));
   ercvScene_Gateway->nodeParticleSystem->setMaterialFlag(video::EMF_LIGHTING, false);
   ercvScene_Gateway->nodeParticleSystem->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);

   // create and set emitter
   scene::IParticleEmitter *partEmBox = ercvScene_Gateway->nodeParticleSystem->createBoxEmitter(
      core::aabbox3d<f32>(-3,0,-3,3,1,3), core::vector3df(0.0f,0.03f,0.0f),
      80,100, video::SColor(0,255,255,255), video::SColor(0,255,255,255), 400,1100);
   ercvScene_Gateway->nodeParticleSystem->setEmitter(partEmBox);
    partEmBox->drop(); partEmBox = 0;

   // create and set affector
   scene::IParticleAffector *partAffFadeOut = ercvScene_Gateway->nodeParticleSystem->createFadeOutParticleAffector();
   ercvScene_Gateway->nodeParticleSystem->addAffector(partAffFadeOut);
    partAffFadeOut->drop(); partAffFadeOut = 0;


After doing the main render loop (not shown), I procede to do cleanup for a new scene:

Code: Select all
    ptrClient->ptrVideo->dvWindow->getSceneManager()->clear();
    ptrClient->ptrVideo->dvWindow->getGUIEnvironment()->clear();
    ptrClient->ptrVideo->dvWindow->getSceneManager()->getMeshCache()->clear();
    ptrClient->ptrVideo->ClearTextures();


The next scene is then loaded and at the first getSceneManager()->drawAll() the program crashes. But only with OpenGL.

I'm going to do some more snooping with the above stuff you guys suggested tomorrow.
Image
User avatar
Rytz
 
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA

Postby Rytz » Sat Feb 02, 2008 9:31 am

Ok so I have a good update on this issue with lots of information.

As stated above, I can only recreate this crash when using OpenGL.

The actual crash is happening inside of COpenGLDriver::setTransform at the following line (after the 4 ETS_TEXTURE_# case selects):
Code: Select all
const bool isRTT = Material.getTexture(i) && Material.getTexture(i)->isRenderTarget();


Material.getTexture(i) is returning a positive value but the actual crash is happening on the Material.getTexture(i)->isRenderTarget().

I tried getting the name of the texture with getName() when I was debugging and it was always garbage.

So I created a new project that uses the Irrlicht example 08.SpecialFX and added the necessary code to recreate the basic flow of my project. I get the same crash with this project. I documented the code that I added and added some debugging "printf"'s for the output.

Here's the source-code to recreate the crash:
Code: Select all
#include <irrlicht.h>
#include <iostream>

using namespace irr;

#pragma comment(lib, "Irrlicht.lib")

// --------------------------------------------------------
// BEGIN EDIT: Event Receiver for Exiting Main Loop
// --------------------------------------------------------
class MyEventReceiver : public IEventReceiver
{
public:

    bool blExit;

   virtual bool OnEvent(const SEvent& event)
   {
       
        // key pressed...
        if (event.EventType == EET_KEY_INPUT_EVENT){
   
            // esc key...
            if (event.KeyInput.Key == 27) blExit = true;
        }

      return false;
   }
};
// --------------------------------------------------------
// END EDIT
// --------------------------------------------------------


int main()
{
   // ask if user would like shadows

   char i;
   printf("Please press 'y' if you want to use realtime shadows.\n");

   std::cin >> i;
   bool shadows = (i == 'y');

   // ask user for driver

   video::E_DRIVER_TYPE driverType;

   printf("Please select the driver you want for this example:\n"\
      " (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\
      " (d) Software Renderer\n (e) Burning's Software Renderer\n"\
      " (f) NullDevice\n (otherKey) exit\n\n");

   std::cin >> i;

   switch(i)
   {
      case 'a': driverType = video::EDT_DIRECT3D9;break;
      case 'b': driverType = video::EDT_DIRECT3D8;break;
      case 'c': driverType = video::EDT_OPENGL;   break;
      case 'd': driverType = video::EDT_SOFTWARE; break;
      case 'e': driverType = video::EDT_BURNINGSVIDEO;break;
      case 'f': driverType = video::EDT_NULL;     break;
      default: return 1;
   }


   // create device and exit if creation failed

   IrrlichtDevice *device =
      createDevice(driverType, core::dimension2d<s32>(640, 480),
      16, false, shadows);


   if (device == 0)
      return 1; // could not create selected driver.

   video::IVideoDriver* driver = device->getVideoDriver();
   scene::ISceneManager* smgr = device->getSceneManager();

// --------------------------------------------------------
// BEGIN EDIT: Create Texture to Keep and Event Receiver
// --------------------------------------------------------
    video::ITexture *txtrKeep = driver->getTexture("../../media/faerie2.bmp");
    MyEventReceiver receiver;
    receiver.blExit = false;
    device->setEventReceiver(&receiver);
// --------------------------------------------------------
// END EDIT
// --------------------------------------------------------


   scene::IAnimatedMesh* mesh = smgr->getMesh(
      "../../media/room.3ds");

   smgr->getMeshManipulator()->makePlanarTextureMapping(
      mesh->getMesh(0), 0.004f);

   scene::ISceneNode* node = 0;

   node = smgr->addAnimatedMeshSceneNode(mesh);
   node->setMaterialTexture(0,   driver->getTexture("../../media/wall.jpg"));
   node->getMaterial(0).SpecularColor.set(0,0,0,0);

   // add animated water

   mesh = smgr->addHillPlaneMesh("myHill",
      core::dimension2d<f32>(20,20),
      core::dimension2d<u32>(40,40), 0, 0,
      core::dimension2d<f32>(0,0),
      core::dimension2d<f32>(10,10));

   node = smgr->addWaterSurfaceSceneNode(mesh->getMesh(0), 3.0f, 300.0f, 30.0f);
   node->setPosition(core::vector3df(0,7,0));

   node->setMaterialTexture(0, driver->getTexture("../../media/stones.jpg"));
   node->setMaterialTexture(1, driver->getTexture("../../media/water.jpg"));

   node->setMaterialType(video::EMT_REFLECTION_2_LAYER);

   // create light

   node = smgr->addLightSceneNode(0, core::vector3df(0,0,0),
      video::SColorf(1.0f, 0.6f, 0.7f, 1.0f), 1200.0f);
   scene::ISceneNodeAnimator* anim = 0;
   anim = smgr->createFlyCircleAnimator (core::vector3df(0,150,0),250.0f);
   node->addAnimator(anim);
   anim->drop();

   // attach billboard to light

   node = smgr->addBillboardSceneNode(node, core::dimension2d<f32>(50, 50));
   node->setMaterialFlag(video::EMF_LIGHTING, false);
   node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
   node->setMaterialTexture(0, driver->getTexture("../../media/particlewhite.bmp"));


   // create a particle system

   scene::IParticleSystemSceneNode* ps = 0;
   ps = smgr->addParticleSystemSceneNode(false);
   ps->setPosition(core::vector3df(-70,60,40));
   ps->setScale(core::vector3df(2,2,2));

   ps->setParticleSize(core::dimension2d<f32>(20.0f, 20.0f));

   scene::IParticleEmitter* em = ps->createBoxEmitter(
      core::aabbox3d<f32>(-7,0,-7,7,1,7),
      core::vector3df(0.0f,0.06f,0.0f),
      80,100,
      video::SColor(0,255,255,255), video::SColor(0,255,255,255),
      800,2000);

   ps->setEmitter(em);
   em->drop();

   scene::IParticleAffector* paf =
      ps->createFadeOutParticleAffector();

   ps->addAffector(paf);
   paf->drop();

   ps->setMaterialFlag(video::EMF_LIGHTING, false);
   ps->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
   ps->setMaterialTexture(0, driver->getTexture("../../media/fire.bmp"));
   ps->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);

   // add animated character

   mesh = smgr->getMesh("../../media/dwarf.x");
   scene::IAnimatedMeshSceneNode* anode = 0;

   anode = smgr->addAnimatedMeshSceneNode(mesh);
   anode->setPosition(core::vector3df(-50,20,-60));
   anode->setAnimationSpeed(15);

   // add shadow
   anode->addShadowVolumeSceneNode();
   smgr->setShadowColor(video::SColor(150,0,0,0));

   // make the model a little bit bigger and normalize its normals
   // because of this for correct lighting
   anode->setScale(core::vector3df(2,2,2));
   anode->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);

   /*
   Finally we simply have to draw everything, that's all.
   */

   scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
   camera->setPosition(core::vector3df(-50,50,-150));

   // disable mouse cursor
   device->getCursorControl()->setVisible(false);

   int lastFPS = -1;

   while(device->run() && !receiver.blExit)
   if (device->isWindowActive())
   {
      driver->beginScene(true, true, 0);

      smgr->drawAll();

      driver->endScene();

      int fps = driver->getFPS();

      if (lastFPS != fps)
      {
         core::stringw str = L"Irrlicht Engine - SpecialFX example [";
         str += driver->getName();
         str += "] FPS:";
         str += fps;

         device->setWindowCaption(str.c_str());
         lastFPS = fps;
      }
   }

// --------------------------------------------------------------------
// BEGIN EDIT: Clear Scene, Remove Textures Except Faerie, Draw Scene
// --------------------------------------------------------------------
printf("\nDEBUG_BEGIN\n");
    smgr->clear();

printf("DEBUG1\n");
    smgr->getMeshCache()->clear();

printf("DEBUG2\n");
    for (long l = driver->getTextureCount() - 1; l >= 0; l--)
        if (driver->getTextureByIndex(l)->getName().find("faerie2.bmp") == -1)
            driver->removeTexture(driver->getTextureByIndex(l));

printf("DEBUG3\n");
    driver->beginScene(true, true, 0);

    // ---- PROGRAM CRASHES HERE ----
printf("DEBUG4\n");
    smgr->drawAll();

printf("DEBUG5\n");
    driver->endScene();

printf("DEBUG6\n");
    driver->removeTexture(txtrKeep); txtrKeep = 0;

printf("DEBUG_END\n");
// --------------------------------------------------------------------
// END EDIT
// --------------------------------------------------------------------

   device->drop();
}


I'll look more at it tomorrow since it's 3:15am here.

Thanks in advance for any suggestions or info.
Last edited by Rytz on Sat Feb 09, 2008 10:03 pm, edited 1 time in total.
Image
User avatar
Rytz
 
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA

Postby Rytz » Sat Feb 02, 2008 10:02 pm

So after more debugging it seems like there is a problem somewhere when removing textures (in OpenGL). If I do the loop below to remove all but 1 texture:
Code: Select all
for (long l = driver->getTextureCount() - 1; l >= 0; l--)
        if (driver->getTextureByIndex(l)->getName().find("faerie2.bmp") == -1)
            driver->removeTexture(driver->getTextureByIndex(l));


I do driver->getTextureCount() afterwards and get the correct count of remaining textures, which should be 1. But further debugging reveals COpenGLDriver::setTransform is attempting to work with a corrupt / bad texture pointer when doing smgr->drawAll().

So I tried using driver->removeAllTextures() just for kicks and I get the same problem when doing smgr->drawAll() afterwards.

Am I doing something wrong or is this a bug? If I want to remove all textures but 1 and then recreate the scene what is the workflow?
Image
User avatar
Rytz
 
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA

Postby vitek » Sun Feb 03, 2008 3:12 am

Sounds like a bug. It would be useful if you could see what is using te texture and where that texture pointer is kept. Should be easy enough to do if you have a debugger.

Travis
User avatar
vitek
Bug Slayer
 
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Postby Rytz » Sun Feb 03, 2008 4:56 am

This bug is happening only with textures added to scene::IParticleSystemSceneNode. I can confirm this with the above project and my own. I'm looking more into it now so I'll post whatever I find.
Image
User avatar
Rytz
 
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA

Postby Rytz » Sun Feb 03, 2008 11:43 pm

I'm still learning the flow of Irrlicht internally but this is what I've come up with so far:

It looks like the address of the texture attached to the scene::IParticleSystemSceneNode isn't being completely removed. I can forcefully set the address to 0 in CNullDriver::removeTexture (see the code below) but in COpenGLDriver::setTransform it's still showing the original texture address.

Code: Select all
//! Removes a texture from the texture cache and deletes it, freeing lot of
//! memory.
void CNullDriver::removeTexture(ITexture* texture)
{

printf("\nDEBUG_removeTexture()\n");

   if (!texture)
      return;

   for (u32 i=0; i<Textures.size(); ++i){
      if (Textures[i].Surface == texture)
      {

printf("DEBUG_removeTexture()_Textures[i].Surface [1]: %i\n", Textures[i].Surface);
printf("DEBUG_removeTexture()_texture [1]: %i\n", texture);

         texture->drop();
Textures[i].Surface = 0;
printf("DEBUG_removeTexture()_Textures[i].Surface [2]: %i\n", Textures[i].Surface);
         Textures.erase(i);
texture = 0;
printf("DEBUG_removeTexture()_texture [2]: %i\n", texture);
      }
    }
}



At what point after removing a texture is the address supposed to be dropped by Irrlicht? Even if my program sets the texture address to 0, Irrlicht is still carrying that original address later on in COpenGLDriver::setTransform.
Image
User avatar
Rytz
 
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA

Postby Rytz » Mon Feb 04, 2008 1:25 am

More investigation reveals that it actually relates to the material not being cleared or reset.

I was able to create a work-around by creating an empty SMateral and doing a setMaterial on it (see below):
Code: Select all
video::SMaterial matBlank;
ps->getMaterial(0) = matBlank;
driver->setMaterial(ps->getMaterial(0));


At what point are materials being cleared out for scene nodes and such?
Image
User avatar
Rytz
 
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA

Postby vitek » Mon Feb 04, 2008 6:09 am

They aren't.

As you've discovered, the driver caches the textures that were set. These textures aren't being properly reference counted, so you get a crash. I consider this a bug, but others may think otherwise. As the documentation says, it is up to you to make sure that nothing references the textures that are removed.

Travis
User avatar
vitek
Bug Slayer
 
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Postby Rytz » Mon Feb 04, 2008 6:15 am

vitek wrote:They aren't.

As you've discovered, the driver caches the textures that were set. These textures aren't being properly reference counted, so you get a crash. I consider this a bug, but others may think otherwise. As the documentation says, it is up to you to make sure that nothing references the textures that are removed.

Travis

I understand what you are saying but I'm just kinda baffled since this only happens in OpenGL and only with the IParticleSystemSceneNode from what I've tested / programmed so far.

If you guys consider this a bug I'll keep looking at it to see if I can throw something in to fix it but if not then I'll just stick with my workaround for now.

EDIT: I also wanted to add that in a way I'm kinda glad this happened cause it finally got my rear in gear to actually get the debugger set up with Dev-CPP.
Image
User avatar
Rytz
 
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA

Postby Rytz » Sun Jul 27, 2008 3:14 am

I was doing some more stuff with removing textures recently and found that an easier work around is to just do the following before removing any textures:

Code: Select all
video::SMaterial matBlank;
IVideoDriver->setMaterial(matBlank);
Image
User avatar
Rytz
 
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA


Return to Beginners Help

Who is online

Users browsing this forum: No registered users and 1 guest

cron