im trying to write an graphics engine, that should be event based.
that means, everything that is done, is done by an event wich is sent out and interpreted.
i use SEvent as base class, derive an tCustomEvent from it and so on.
now i have a problem. these are the important functions:
Code To Send Out Event, a simple run function wich does only 20 frames, and the OnEvent function from IEventReceiver, wich should be used to interpret all the incoming events.
Code: Select all
void app::sendOutEvent(const tCustomEvent& ev)
{
device->postEventFromUser(ev);
};
void app::run(void)
{
s32 frames = 0;
while(device->run() && ++frames < 20)
{
printf("FRAME %i\n", frames);
sendOutEvent(tCustomEvent());
sendOutEvent(tPrintStringEvent("TEST YEAH"));
};
};
bool app::OnEvent(const SEvent& event)
{
switch(event.EventType)
{
case EET_USER_EVENT:
{
tCustomEvent cEvent = (tCustomEvent&)event;
printf("CET = %i\n", cEvent.type);
switch(cEvent.type)
{
case CET_BASE:
{
printf("CET_BASE event received!\n");
return true;
};break;
case CET_PRINT_STRING:
{
tPrintStringEvent psEvent = (tPrintStringEvent&)cEvent;
printf("CET_PRINT_STRING event received!\n");
printf("String Received : ");
psEvent.printString();
printf("\n");
return true;
};break;
default:
return false;
};
};break;
default : return false;
};
return false;
};
Code: Select all
#ifndef CUSTOMEVENTS_H
#define CUSTOMEVENTS_H
#include "irrlicht.h"
using namespace irr;
enum customEventType
{
CET_BASE = 1,
CET_PRINT_STRING
};
class tCustomEvent : public SEvent
{
public:
tCustomEvent()
{
SEvent::EventType = EET_USER_EVENT;
type = CET_BASE;
};
virtual ~tCustomEvent()
{
};
customEventType type;
};
class tPrintStringEvent : public tCustomEvent
{
public:
tPrintStringEvent(const c8* string) : array(string)
{
tCustomEvent::type = CET_PRINT_STRING;
};
virtual ~tPrintStringEvent()
{
delete array;
};
inline const c8* getString(void)
{
return array;
};
inline void printString(void) const
{
printf(array);
};
private:
const c8* array;
};
#endif //CUSTOMEVENTS_H
i can even see, wich type of tCustomEvent it is (this is a simplified piece of the whole code
the string wich is printed is all 20 frames the same, but not the one i gave to the sended event.
i have an 64-bit vista, maybe the problem has something to do with that?
please help me out peolpe i'm relly stuck on this one and it is important to me!!