TechDemo with 0.4.2

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
Battlestations
Posts: 10
Joined: Sun Jan 18, 2004 10:46 pm
Location: USA
Contact:

TechDemo with 0.4.2

Post by Battlestations »

Ok i rebuilt the Techdemo to use the new 0.4.2 dll.
The main page loads, with all of its settings etc., but when I try to load the bsp it crashes, It stops on:

Code: Select all

bool CDemo::OnEvent(SEvent event)
{
	if (event.EventType == EET_KEY_INPUT_EVENT &&
		event.KeyInput.Key == KEY_ESCAPE &&
		event.KeyInput.PressedDown == false)
	{
		// user wants to quit.
		device->closeDevice();
	}
	else
	if ((event.EventType == EET_KEY_INPUT_EVENT &&
		event.KeyInput.Key == KEY_SPACE &&
		event.KeyInput.PressedDown == false) ||
		(event.EventType == EET_MOUSE_INPUT_EVENT &&
		event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) &&
		currentScene == 3)
	{
		// shoot 
		shoot();
	}
	else
	if (device->getSceneManager()->getActiveCamera())//Hangs here
	{
		device->getSceneManager()->getActiveCamera()->OnEvent(event);
		return true;
	}

	return false;
}
Well I tried stepping through it, but i dont see why its not working..
Anyone care to tell me whats wrong with it? I didn't change any thing in the demo at all. I am trying to get it to run with the new dll.
Battlestations
Posts: 10
Joined: Sun Jan 18, 2004 10:46 pm
Location: USA
Contact:

Ok i went and tried something and it worked.

Post by Battlestations »

I modified a few things to make it work.
It seems the event for the scene was being accessed before it was even available.

So i added something to get it to work. Heres what i did.

in Main.cpp

Code: Select all

	if (menu.run(fullscreen, music, shadows, driverType))
	{
		CDemo demo(fullscreen, music, shadows, driverType);
		demo.loading = false; //add this line
		demo.run();		
	}
In CDemo.h:

Code: Select all


class CDemo : public IEventReceiver
{
public:

	CDemo(bool fullscreen, bool music, bool shadows, video::EDriverType driver);

	~CDemo();

	void run();

	virtual bool OnEvent(SEvent event);

	bool loading; //add this line

private:

in CDemo.cpp: Find void CDemo::run()
add this:

Code: Select all

	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();
	loading = true; //for event to continue scene events < --ADD this
	gui::IGUIEnvironment* guienv = device->getGUIEnvironment();

and finally in

Code: Select all

bool CDemo::OnEvent(SEvent event) 
{ 
   if (event.EventType == EET_KEY_INPUT_EVENT && 
      event.KeyInput.Key == KEY_ESCAPE && 
      event.KeyInput.PressedDown == false) 
   { 
      // user wants to quit. 
      device->closeDevice(); 
   } 
   else 
   if ((event.EventType == EET_KEY_INPUT_EVENT && 
      event.KeyInput.Key == KEY_SPACE && 
      event.KeyInput.PressedDown == false) || 
      (event.EventType == EET_MOUSE_INPUT_EVENT && 
      event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) && 
      currentScene == 3) 
   { 
      // shoot 
      shoot(); 
   } 
   else 
   if (loading == true && device->getSceneManager()->getActiveCamera())//Change this
   { 
      device->getSceneManager()->getActiveCamera()->OnEvent(event); 
      return true; 
   } 

   return false; 
} 

It should now load.
Post Reply