Im having some trouble with the following program - basically when i run it and click the "new window" button, it freezes and the windows error report message comes up (the graphical window closes, but the console window doesnt (comes up with "press any key" that you get at the end of a standard console app))
...I didnt really know what i could search for to answer this problem so sorry if its been asked already..
Code: Select all
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#pragma comment (lib, "Irrlicht.lib")
IrrlichtDevice* device = 0;
s32 counter = 0;
IGUIListBox* listBox = 0;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent (SEvent event)
{
if(event.EventType == EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();
gui::IGUIEnvironment* GUIEnv = device->getGUIEnvironment();
switch(event.GUIEvent.EventType)
{
case EGET_BUTTON_CLICKED:
{
if(id == 101)
{
listBox->addItem(L"Window Created");
counter+=30;
if(counter > 200)
counter = 0;
IGUIWindow* window = GUIEnv->addWindow(rect<s32>(100+counter,
100+counter, 300+counter,
200+counter), false, L"Test");
GUIEnv->addStaticText(L"Close me", rect<s32>(35,35,140,50),
true, false, window);
}
break;
}
default:
break;
}
return true;
}
return false;
}
};
int main()
{
device = createDevice(video::EDT_DIRECTX8, core::dimension2d<s32>(640,480));
if(device==0)
return 1;
MyEventReceiver receiver;
device->setEventReceiver(&receiver);
device->setWindowCaption(L"This will eventually be a calcluator");
video::IVideoDriver* driver = device->getVideoDriver();
IGUIEnvironment* env = device->getGUIEnvironment();
env->addButton(rect<s32>(10,250,100,290), 0, 101, L"New Window");
while(device->run() && driver)
if(device->isWindowActive())
{
driver->beginScene(true, true, SColor(0, 0, 0, 255));
env->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
[/code]