toggling FPSCamera event receiving

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
agrif

toggling FPSCamera event receiving

Post by agrif »

I feel bad about posting twice in a short time, but...

I am trying to use the TAB key to toggle between Camera mode and Gui mode, and to do this, I use camera->setInputEventReceiver();

When I use this right after declaring the camera, it works fine. But in an event receiver, it crashes, and windows makes an "error log" that you can never find.

My event receiver:

Code: Select all

bool XSM::OnEvent(SEvent event) {
    bool on;
    if (event.EventType == EET_GUI_EVENT) {
        return igg->OnEvent(event);
    } else if (event.EventType == EET_KEY_INPUT_EVENT && event.KeyInput.PressedDown == false && 
        device != 0 && camera != 0) {
        switch (event.KeyInput.Key) {
                case KEY_TAB:
                if (cameraOn) {
                                cout << "Tis on!" << endl;
                                 
                                camera->setInputReceiverEnabled(false);// crashes right here 
                                cout << "Now Off!" << endl;
                                device->getCursorControl()->setVisible(true);
                } else {
                                camera->setInputReceiverEnabled(true);
                                device->getCursorControl()->setVisible(false);
                }
                
                case KEY_ESCAPE:
                                device->closeDevice();
        }
    }
    return false;
}
sry for the close posts

:(

agrif
Post Reply