This is my very short programm for testing the GUI. I´ve compiled it with the MS Visual Studio 2005 Express Edition, without any compiler-erroers or warnings. But every time the program crashed, when I pressed the Button (ID 101).
// ========================================================================================================
//
// Includedateien einbinden :
#include "Main.h"
// ========================================================================================================
// ========================================================================================================
//
// Globale Hilfsvariablen :
IrrlichtDevice *device = 0;
s32 cnt = 0;
// ========================================================================================================
//
// Eventreciever - Ereignissabfrage Funktinion :
class MyEventReceiver : 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 EGET_BUTTON_CLICKED:
if (id == 101)
{
device->closeDevice();
return true;
}
if (id == 102)
{
return true;
}
break;
default:
break;
}
}
return false;
}
};
// ========================================================================================================
//
// Haupteinsprungpunkt des Programms :
int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
// Das Irrlicht (SOFTWARE DEVICE) wird erzeugt
IrrlichtDevice *device =
createDevice (EDT_SOFTWARE, dimension2d<s32>(640,480), 32, false, false, false, 0);
MyEventReceiver receiver;
device->setEventReceiver(&receiver);
device->setWindowCaption(TEXT ("Tertium"));
IVideoDriver* driver = device->getVideoDriver();
IGUIEnvironment* env = device->getGUIEnvironment();
IGUISkin* skin = env->getSkin();
IGUIFont* font = env->getFont("D4O.bmp");
if (font) skin->setFont(font);
env->addButton(rect<s32>(416, 424, 616, 460), 0, 101, TEXT ("Beenden"));
env->addButton(rect<s32>(416, 376, 616, 412), 0, 102, TEXT ("Optionen"));
while (device->run() && driver)
if (device->isWindowActive())
{
driver->beginScene (true, true, SColor(255, 160, 120, 80));
env->drawAll();
driver->endScene();
}
device->drop();
return (0);
}
Error :
Need help to solve this problem !Unbehandelte Ausnahme bei 0x00411b91 in Irrlicht2.exe: 0xC0000005: Zugriffsverletzung beim Lesen an Position 0x00000000.