problem in loading scene with smgr->loadScene

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.
Post Reply
wiznoe
Posts: 8
Joined: Wed Jun 18, 2008 4:40 am
Location: Jogja, Indonesia

problem in loading scene with smgr->loadScene

Post 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????
}
Last edited by wiznoe on Wed Jun 25, 2008 3:52 am, edited 2 times in total.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post 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?
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
TomiZ
Posts: 40
Joined: Wed Aug 29, 2007 6:02 am
Location: Poland
Contact:

Post 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.
wiznoe
Posts: 8
Joined: Wed Jun 18, 2008 4:40 am
Location: Jogja, Indonesia

problem in loading scene

Post 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:
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply