silly runtime error!

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
Gav
Posts: 23
Joined: Fri Jul 16, 2004 12:28 pm

silly runtime error!

Post by Gav »

:oops: probably just a silly thing I've done/forgotten anyway I was hoping it wouldnt come to this . . but here's a (small) pile of code:

Code: Select all

#include <iostream.h>
#include <irrlicht.h>
#include "definitions.h"

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

using namespace irr;

//////////////////////////////
//Globals
//////////////////////////////
IrrlichtDevice* device = NULL;
video::IVideoDriver* driver = NULL;
scene::ISceneManager* smgr = NULL;
gui::IGUIEnvironment* guienv = NULL;

GAMESTATE state = MENU;

///////////////////////////////
//Menu Event Receiver
///////////////////////////////
class MenuEventReceiver : public IEventReceiver
{
public:
	virtual bool OnEvent(SEvent event)
	{
		if (event.EventType == EET_GUI_EVENT)
		{
			s32 id = event.GUIEvent.Caller->getID();

            switch(event.GUIEvent.EventType)
            {
			case gui::EGET_BUTTON_CLICKED:
					if (id == MENU_QUIT)
					{
						device->closeDevice();
						return true;
					}

					if (id == MENU_NEWGAME)
					{
						//does nothing yet!
						return true;
					}
					break;
			}
       }
       return false;
    }
 };

////////////////////////////
//Forward Declarations
////////////////////////////
bool init();
void initMenu();
void render();
void cleanup();

////////////////////////////
//Main loop
////////////////////////////
int main()
{
	init();
	initMenu();
	while(device->run())
	{
		render();
	}
	cleanup();
	return 0;
}

///////////////////////
//Init
///////////////////////
bool init()
{
	device = createDevice(video::EDT_DIRECTX8,
				core::dimension2d<s32>(WINDOW_WIDTH, WINDOW_HEIGHT),
				BITRATE, false, false, false, 0);
	device->setWindowCaption(L"Window Caption");

	driver = device->getVideoDriver();
	smgr = device->getSceneManager();
	guienv = device->getGUIEnvironment();

	MenuEventReceiver receiver;
	device->setEventReceiver(&receiver);

	return true;
}

///////////////////////
//Cleanup
////////////////////////
void cleanup()
{
	device->drop();
}

///////////////////////
//InitMenu
///////////////////////
void initMenu()
{
	guienv->addButton(core::rect<s32>(10, 210, 100, 240), 0, MENU_QUIT, L"QUIT");
	guienv->addButton(core::rect<s32>(10, 300, 100, 340), 0, MENU_NEWGAME, L"NEWGAME");
}

///////////////////////
//Render
///////////////////////
void render()
{
	//Begin rendering
	driver->beginScene(true, true, video::SColor(255, 89, 68, 43));

	//Do rendering
	smgr->drawAll();
	guienv->drawAll();

	//End rendering
	driver->endScene();
}
:P

In addition to helping solve the problem can someone tell me how I go about detecting errors and outputting them in irrlicht as im sure that would help!

Thanks!
Guest

Post by Guest »

What is the runtime error?, ... :?
Gav
Posts: 23
Joined: Fri Jul 16, 2004 12:28 pm

Post by Gav »

I dont know thats why im asking here!

I have dr. watson log file from the crash but it makes no sense to me.
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Can we see the definitions.h file?
Image
Gav
Posts: 23
Joined: Fri Jul 16, 2004 12:28 pm

Post by Gav »

here it is:

Code: Select all

const int WINDOW_WIDTH	= 800;
const int WINDOW_HEIGHT	= 600;
const int BITRATE		= 32;
enum GAMESTATE {MENU, QUIT, GAME};

//GUI ID NUMBERS
const int MENU_QUIT		 = 101;
const int MENU_NEWGAME = 102;
Post Reply