O'Reilly logo

Irrlicht 1.7 Realtime 3D Engine by Aung Sithu Kyaw, Johannes Stein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - adding buttons to your GUI

We are going to use the example from the last exercise.

  1. Add a struct called SAppContext that contains IrrlichtDevice* device.
  2. Add an enum with two states. One called GUI_ID_QUIT_BUTTON, which should be initialized with the value 101 and the other should be called GUI_ID_NEW_WINDOW_BUTTON.
  3. We need our own event receiver class that inherits from IEventReceiver, which is going to handle the events if we press one of our buttons:
    class MyEventReceiver: public IEventReceiver { public: MyEventReceiver(SAppContext & context) : Context(context) { } virtual bool OnEvent(const SEvent& event) { if (event.EventType == EET_GUI_EVENT) { s32 id = event.GUIEvent.Caller->getID(); IGUIEnvironment* guienv = Context.device- ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required