[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

#### 4.2.1.2 app.h

In this header file we declare our main application class. This is the class where we store references to commonly used modules from Crystal Space and Crystal Entity Layer. This is also the class that contains the main event handling loop.

    #ifndef APP_H
    #define APP_H

    #include <physicallayer/entity.h>
    #include <physicallayer/pl.h>

    /*
     * Our main application class inherits from csApplicationFramework
     * and csBaseEventHandler.
     */
    class MainApp : public csApplicationFramework,
                    public csBaseEventHandler
    {
    private:
      // References to modules from Crystal Space.
      csRef<iGraphics3D> g3d;
      csRef<iEngine> engine;
      csRef<iLoader> loader;
      csRef<iVFS> vfs;
      csRef<iVirtualClock> vc;
      csRef<iKeyboardDriver> kbd;

      // References to modules from Crystal Entity Layer.
      csRef<iCelPlLayer> pl;
      csRef<iCelBlLayer> bl;

      // Our level and player entity.
      csRef<iCelEntity> level_entity;
      csRef<iCelEntity> player_entity;

      // Inherited from csBaseEventHandler: handle a keyboard event.
      bool OnKeyboard (iEvent&);

      // Inherited from csBaseEventHandler: handle a signle frame.
      void ProcessFrame ();
      // Inherited from csBaseEventHandler: handle a signle frame.
      void FinishFrame ();

      // Create the level entity and load the level in it.
      // Returns false on failure. The error has been already reported to
      // the reporter in that case.
      bool LoadLevel ();

      // Create the player.
      // Returns false on failure. The error has been already reported to
      // the reporter in that case.
      bool CreatePlayer ();

    public:
      MainApp ();
      virtual ~MainApp ();

      // Inherited from csApplicationFramework: initialization.
      virtual bool OnInitialize (int argc, char* argv[]);

      // Inherited from csApplicationFramework: initialization.
      virtual bool Application ();
    };

    #endif

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ]

This document was generated using texi2html 1.76.