Page 1 of 1

problem in loading scene with smgr->loadScene

Posted: Wed Jun 18, 2008 5:45 am
by wiznoe
I have an error when i'm debug my program, this is my code:

Code: Select all

#include "preamble.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

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

int main() {
	//MyEventReceiver receiver;
	IrrlichtDevice *device = createDevice(EDT_DIRECT3D8,
						  dimension2d<s32>(800,600),
						  16, //bit
						  false, //fullscrenn
						  false, //stencilbufer (bayangan)
						  false);
						
	video::IVideoDriver* driver = device->getVideoDriver();
    scene::ISceneManager* scenemgr = device->getSceneManager();

	IGUIEnvironment* env = device->getGUIEnvironment();
	

	//layar pertama	
	ITexture * background = 0;	
	IGUIFont * fontjudul = env->getFont("Fonts/franklin_gothic.xml");
	IGUIFont * fonttombol = env->getFont("Fonts/arialblack_14.xml");
	env->getSkin()->setFont(fonttombol);
	array<IGUIButton*> butons;
	menu_state state;
	state = MS_PEMBUKAAN;
	bool loaded = false;

	while (device->run()){
		driver->beginScene(true, true, video::SColor(255,128,128,128));
		switch (state){			
			case MS_PEMBUKAAN:
				if(!loaded){
					driver->removeAllTextures();
					pembuka(driver,env,butons);
					loaded = true;
				}
				if(butons.size()>0)
				if(butons[0]->isPressed()){
					loaded = false;
					state = MS_MENU;
					butons.clear();
				}
				break;
			case MS_MENU:
				if(!loaded){
					driver->removeAllTextures();
					//menu(driver,env,butons);
					liat3D(scenemgr,driver,env,butons);
					loaded = true;
				}
				break;
		}
		driver->setViewPort(rect<s32>(20,20,500,500));
		scenemgr->drawAll();
		driver->setViewPort(rect<s32>(0,0,800,600));
		env->drawAll();
        driver->endScene();
	}
	return 0;
}

below are the code for class liat3D which are called when the case are MS_MENU:

void liat3D(ISceneManager* smgr, IVideoDriver* driver, IGUIEnvironment* &env, array<IGUIButton*> &butons){
	env->clear();
	butons.push_back(env->addButton(rect<s32>(640,480,780,510),0,-1,L"kucing",L"kucing"));	
	butons.push_back(env->addButton(rect<s32>(640,540,780,570),0,-1,L"anjing",L"anjing"));	
	smgr->loadScene("scenes/tipe45.irr"); // i think this is my prob. how2fix????
}

Posted: Wed Jun 18, 2008 6:03 am
by BlindSide
The problem is actually inside smgr->drawAll() (MSVC usually displays the line right after the one that's actually causing trouble). This could mean anything, more than likely an incorrectly initialised scene node is causing an exception when it's being rendered. I've had this problem sometimes when loading animated mesh scene nodes that are actually non-animated. Could you try not adding any scene nodes and see if this error still occurs?

Posted: Wed Jun 18, 2008 2:21 pm
by TomiZ
Try without this line
driver->removeAllTextures();

If you remove texture every scene node that use it will cause error when smgr->drawAll() is called.

I'm not sure if GUI fonts aren't destroy after removing textures.

problem in loading scene

Posted: Tue Jun 24, 2008 10:21 am
by wiznoe
I’ve tried not adding any scene nodes and there were no error occurred. I don’t get your idea about “incorrectly initialised scene node”. How to fix it?
So how can I load the scene, if I should not adding any scene?
What if I say that mistake(s) on this line “smgr->loadScene("scenes/tipe45.irr")”. Coz wherever I putted the line, the error are always pointing to this line.
Oh, one thing. The scene loaded are not animated one.
:cry:

Posted: Tue Jun 24, 2008 12:11 pm
by rogerborg
You're loading a scene after calling beginScene(), which seems unlikely to be safe.

What error do you get?

Why can't you use your debugger to investigate it?