my app reads a scene file, load's it in a new scene manager and saves the path to the scene file, the path to a screenshot of that scene and the name of the scene(just for showing on the gui), and stores this values in stringc/stringw vars, then... then takes the screenshot and writes the screenshot to file, then clears and drop the created scene manager.
here's the code:
sceneData.h
Code: Select all
#include <irrlicht.h>
#include <iostream>
using namespace irr;
class sceneData
{
public:
sceneData(IrrlichtDevice *Device, c8* scene);
sceneData(wchar_t* name, c8* file, s32 conv);
core::stringw getName();
core::stringc getSceneFile();
core::stringc getPreview();
s32 unitsToMts();
private:
core::stringc preview;
core::stringw sceneName;
core::stringc sceneFile;
s32 unitConst;
};
Code: Select all
sceneData::sceneData(IrrlichtDevice *Device, c8* scene)//constructor of the sceneData holding object
{
video::IImage* img = 0;
scene::ISceneManager* smgr = Device->getSceneManager()->createNewSceneManager(false);//new SceneManager
dataSerializer* serializer = new dataSerializer(Device, &sceneName, &unitConst);//create a serializer to load scenes
if(smgr->loadScene(scene, serializer))//Load the scene using the serializer
Device->getLogger()->log("Scene loaded in second scene manager");
else
Device->getLogger()->log("Failed to load scene in second scene manager");
core::stringc temp1 = core::stringc("../media/screenShots/");
sceneName.make_lower();
temp1.append(sceneName.c_str());
temp1.append(".jpg");
preview = core::stringc(temp1);//the filename for the scenePreview
Device->getLogger()->log(preview.c_str());
temp1 = core::stringc("../media/models/");
temp1.append(sceneName.c_str());
temp1.append(".irr");
temp1.make_lower();
sceneFile = core::stringc(temp1);
Device->getLogger()->log(sceneFile.c_str());
if(smgr->saveScene(sceneFile.c_str()))
Device->getLogger()->log("scene saved in second scene manager");
else
Device->getLogger()->log("Failed to save scene");
Device->getVideoDriver()->beginScene(true, true, video::SColor(255,100,101,140));//render one frame
smgr->drawAll();//drawing the scene
Device->getVideoDriver()->endScene();//end of scene
img = Device->getVideoDriver()->createScreenShot();//creates screenshot, Bad pointer here
if(Device->getVideoDriver()->writeImageToFile(img, preview.c_str()))//this returns false
Device->getLogger()->log("Screenshot saved");//never happends
else
Device->getLogger()->log("Failed to write screenshot");
img->drop();//dropping the created image
smgr->clear();//clearing the sceneManager
smgr->drop();//Dropping the created scene manager
return;
}
core::stringw sceneData::getName()
{
return sceneName;
}
core::stringc sceneData::getSceneFile()
{
return sceneFile;
}
core::stringc sceneData::getPreview()
{
return preview;
}
and... when i try to load the scene using the info in the above object, i get the couldnt load xxxxx.irr /xxxx.jpg file...
the files are there(i made them manually in main using explicit path instead of getting them from the .irr file) and even so it wont load them... like the path was invalid... again thats what got me thinking that the problem is in the strings, but i cant find it, is probably a nobb c++ error
any ideas? if necesary i can provide the code where this is used/called
thanks in advance