What if...

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.
Halan
Posts: 447
Joined: Tue Oct 04, 2005 8:17 pm
Location: Germany, Freak City
Contact:

What if...

Post by Halan »

... the code compiles without warnings but the game crashes at device creation (found out via logger)

is it releated to the dll?

greets,
Halan
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, it's due to null pointer in your code. Try to debug your app which null pointer it is, or even better try to check every return value.
Halan
Posts: 447
Joined: Tue Oct 04, 2005 8:17 pm
Location: Germany, Freak City
Contact:

Post by Halan »

thanks,
can this be the only reason?

btw, this is the intialize function :

Code: Select all

bool intialize()
{
   //Create Device and Stuff
   LogWrite("LOG TEST \n");
   device = createDevice(EDT_OPENGL, dimension2d<s32>(800, 600), 32, false, true, true, &receiver);
   device->setWindowCaption(L"Age of War - Server v0.1.0");
   LogWrite("Device and MSWindow created \n");
   driver = device->getVideoDriver();
   LogWrite("OpenGL Manager created \n");
   env = device->getGUIEnvironment();
   LogWrite("GUI Manager created \n");
   smgr = device->getSceneManager();
   LogWrite("Scene Mangaer Created \n");
   timer = device->getTimer();
   timer->start();
   timer->setSpeed(1.0f);
   LogWrite("Timer created and started \n");
   return true;
}
LOG TEST is shown in the log file ... then it crashed :(
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I guess it's the receiver which is not correctly initialized.
Halan
Posts: 447
Joined: Tue Oct 04, 2005 8:17 pm
Location: Germany, Freak City
Contact:

Post by Halan »

thanks,

i checked it but i cant find a probelm :( so i thought maybe coping to the forum would be the only solution its based on the "key and mouse input" thread in the FAQ/Howto-Forum

Code: Select all

class CReceiver : public IEventReceiver
{
public:
bool OnEvent(SEvent event)
{
   if(event.MouseInput.Event == EMIE_MOUSE_WHEEL)
   {
      MouseWeel=event.MouseInput.Wheel;
      return true;
   } 

   if(event.EventType == EET_KEY_INPUT_EVENT)//if the keys gave input
   {
      keys[event.KeyInput.Key] = event.KeyInput.PressedDown;//we set it on if it was pushed, off if it was let up
      return true;
   }

   if(event.GUIEvent.EventType == EGET_BUTTON_CLICKED)
   {
      GUIButton = event.GUIEvent.Caller->getID(); 
      return true;                         
   }

   if(event.EventType == EET_MOUSE_INPUT_EVENT)
   {
      //left mouse button
      if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
      {
          keys[KEY_LBUTTON] = 1;//on
          return true;
      }
      if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP)
      {
         keys[KEY_LBUTTON] = 0;//off
         return true;
      }
      //middle mouse button
      if (event.MouseInput.Event == EMIE_MMOUSE_PRESSED_DOWN)
      {
         keys[KEY_MBUTTON] = 1;//on
         return true;
      }
      if (event.MouseInput.Event == EMIE_MMOUSE_LEFT_UP)
      {
         keys[KEY_MBUTTON] = 0;//off
         return true;
      }
      //right mouse button
      if (event.MouseInput.Event == EMIE_RMOUSE_PRESSED_DOWN)
      {
         keys[KEY_RBUTTON] = 1;//on
         return true;
      }
      if (event.MouseInput.Event == EMIE_RMOUSE_LEFT_UP)
      {
         keys[KEY_RBUTTON] = 0;//off
         return true;
      }
      return false;
   }
   return false;
}
};
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Question is not what happens inside the EventReceiver, but if the receiver variable is properly instantiated to good values (i.e. is an object of the class shown).
Halan
Posts: 447
Joined: Tue Oct 04, 2005 8:17 pm
Location: Germany, Freak City
Contact:

Post by Halan »

sry i dont get it :oops:

i mean the receiver gets instantaited like this

Code: Select all

CReceiver receiver;
but what do you mean with good values?
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, but is this instance also used in your method shown above (as it takes no parameters it's hard to tell whether this variable is propagated correctly or some nonsense variable is used).
stodge
Posts: 216
Joined: Fri Dec 05, 2003 5:57 pm

Post by stodge »

What does the debugger show you?
Halan
Posts: 447
Joined: Tue Oct 04, 2005 8:17 pm
Location: Germany, Freak City
Contact:

Post by Halan »

it told me that theres sometihng wrong with that (when i remove it the application works...)

Code: Select all

if(event.GUIEvent.EventType == EGET_BUTTON_CLICKED)
{
    GUIButton = event.GUIEvent.Caller->getID(); 
    eturn true;                         
 }
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Yes, two errors !!! ;)

1st: it's an IGUIButton
2nd: you get a reference not the complete object IGUIButton*
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

:roll:
GUIButton is obviously a variable, otherwise it would lack the variable name!
So storing the ID in a variable is ok. And you should use 'return' instead of eturn. But honestly, the error is somewhere else.
Halan
Posts: 447
Joined: Tue Oct 04, 2005 8:17 pm
Location: Germany, Freak City
Contact:

Post by Halan »

no, acki
i know what you mean but my s32 GUIButton just stores the id of the button that has been pushed.

yeah hybird the error must be something else it says "segmentation error" in the debugger...
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Yes, I see !!!
He's getting the ID, I was overlooking, I thought he gets the caller instead...
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Halan
Posts: 447
Joined: Tue Oct 04, 2005 8:17 pm
Location: Germany, Freak City
Contact:

Post by Halan »

ive to add that my interface is drawn every scene but doesnt react on mouse input :(
so there must be something wrong with the Inerface stuff... any ideas?

@Acki: why did you added the ChatBox to your IrrExtensions but not the extended Table Control?
Post Reply