Wartbed:Manual/Booting and shutting down WARTBED

From Dark Omen Wiki

(Difference between revisions)
Jump to: navigation, search
(+stub)
(Source code and more explanations)
Line 3: Line 3:
==Booting the system==
==Booting the system==
-
To initialise WARTBED you call the static createInstance method of the Wartbed singleton class.  
+
To initialise WARTBED you call the static createInstance method of the Wartbed singleton class. The parameter is the name of the application, and will among other places be written in the caption of the application window.  
-
<div style="margin:2em;"><source lang="cpp">
+
<div style="margin:1em; padding:1em; background:rgb(175,200,175);"><source lang="cpp">
#include "Wartbed.h"
#include "Wartbed.h"
Line 12: Line 12:
}
}
</source></div>
</source></div>
-
You can store the returned object reference for quick access, or you can obtain a reference to the Warbed object at any time after initialisation from the singleton's getSingelton method:
+
You can store the returned object reference for quick access, or you can obtain a reference to the Warbed object at any time after initialisation from the singleton's <tt>getSingelton</tt> method. For consistency of nomenclature, WARTBED follows OGRE 3D's naming convention of calling the singleton access method "getSingleton". WARTBED does however not provide the <tt>getSingletonPtr</tt> method.
-
<div style="margin:2em;"><source lang="cpp" style="margin:1em; border:1px dashed gray; padding:1em;">
+
<div style="margin:1em; padding:1em; background:rgb(175,200,175);"><source lang="cpp" style="margin:1em; border:1px dashed gray; padding:1em;">
-
Wartbed &rWB = Wartbed::getSingleton();
+
Wartbed &wartbed = Wartbed::getSingleton();
</source></div>
</source></div>
==Listeners, Input Bindings and Event Managers==
==Listeners, Input Bindings and Event Managers==
-
Stub
+
There are three principal listener objects that governs application execution. Two are input listeners, <tt>MouseListener</tt> and <tt>KeyboardListener</tt>, and the final, <tt>FrameListener</tt>, monitors OGRE's update cycle. When WARTBED is booted, default input and frame listeners are provided. If WARTBED's input event system is initialised, input listeners integrated with the input event system replace the defaults. Likewise, if the GUI system is initialised, composite input listeners for both input and gui events are set - the GUI system requires the input event system.
-
<div style="margin:2em;"><source lang="cpp">
+
 
 +
Input events are triggered when a key or mouse combination specified in the key bindings section of the configuration file is performed. This event is sent to the event manager function. If no event manager is provided the WARTBED default one is used. Specialised event managers should forward to the default event manager function if it hasn't handled the event. Event though facilities for manually changing input listeners are provided, there should seldom, if ever, be any reason to replace those provided automatically.
 +
<div style="margin:1em; padding:1em; background:rgb(175,200,175);"><source lang="cpp">
namespace myapp
namespace myapp
{
{
Line 37: Line 39:
==GUI and the Tableau==
==GUI and the Tableau==
Stub
Stub
-
<div style="margin:2em;"><source lang="cpp">
+
<div style="margin:1em; padding:1em; background:rgb(175,200,175);"><source lang="cpp">
void SomeFunc()
void SomeFunc()
{
{
Line 45: Line 47:
==Resources==
==Resources==
-
Stub
+
Stub. Currently using OGRE's resource management system. These low-level details will be hidden from sight. Currently all folders and archives to be used must be provided and initialised.
-
<div style="margin:2em;"><source lang="cpp">
+
<div style="margin:1em; padding:1em; background:rgb(175,200,175);"><source lang="cpp">
void SomeFunc()
void SomeFunc()
{
{
Line 58: Line 60:
==Running the App==
==Running the App==
-
Stub
+
An WARTBED application is a loop, preferably updated from a provided frame listener. If so, when resources are loaded, running is merely a question of engaging the auto pilot by invoking the <tt>mainLoop</tt> method:
-
<div style="margin:2em;"><source lang="cpp" style="margin:1em; border:1px dashed gray; padding:1em;">
+
<div style="margin:1em; padding:1em; background:rgb(175,200,175);"><source lang="cpp" style="margin:1em; border:1px dashed gray; padding:1em;">
-
rWB.mainLoop();
+
wartbed.mainLoop();
</source></div>
</source></div>
 +
The application will run until an event named "quit" event is encountered.
==Shutting down==
==Shutting down==
-
Stub
+
Send the message "quit" to the event manager. By default, a "quit" event is mapped to the ESCAPE button. Deallocation of all resources allocated within the framework or by using framework methods is taken care of automatically.  
-
Send the message "quit" to the event manager. All deallocation is taken care of automatically.
+
[[category:Manual]]
[[category:Manual]]

Revision as of 23:59, 22 January 2010


Contents

Booting the system

To initialise WARTBED you call the static createInstance method of the Wartbed singleton class. The parameter is the name of the application, and will among other places be written in the caption of the application window.

#include "Wartbed.h"
 
int main()
{
    Wartbed &rWB = Wartbed::createInstance( "My WARTBED App Name" );
}

You can store the returned object reference for quick access, or you can obtain a reference to the Warbed object at any time after initialisation from the singleton's getSingelton method. For consistency of nomenclature, WARTBED follows OGRE 3D's naming convention of calling the singleton access method "getSingleton". WARTBED does however not provide the getSingletonPtr method.

Wartbed &wartbed = Wartbed::getSingleton();

Listeners, Input Bindings and Event Managers

There are three principal listener objects that governs application execution. Two are input listeners, MouseListener and KeyboardListener, and the final, FrameListener, monitors OGRE's update cycle. When WARTBED is booted, default input and frame listeners are provided. If WARTBED's input event system is initialised, input listeners integrated with the input event system replace the defaults. Likewise, if the GUI system is initialised, composite input listeners for both input and gui events are set - the GUI system requires the input event system.

Input events are triggered when a key or mouse combination specified in the key bindings section of the configuration file is performed. This event is sent to the event manager function. If no event manager is provided the WARTBED default one is used. Specialised event managers should forward to the default event manager function if it hasn't handled the event. Event though facilities for manually changing input listeners are provided, there should seldom, if ever, be any reason to replace those provided automatically.

namespace myapp
{
    // Forward definitions
    void ExecuteEvent( wb::input::MAPPING const &event, long data );
    struct FrameListener;
}
 
void someFunc()
{
    wartbed.setEventManager( myapp::ExecuteEvent );
    wartbed.setFrameListener( FRAMELISTENER_PTR(new myapp::FrameListener) );
    wartbed.readInputBindings( "../cfg/application.config" );
}

GUI and the Tableau

Stub

void SomeFunc()
{
    wartbed.initialiseGUI();
}

Resources

Stub. Currently using OGRE's resource management system. These low-level details will be hidden from sight. Currently all folders and archives to be used must be provided and initialised.

void SomeFunc()
{
    ADD_RESOURCE_LOCATION( "./ogre example skybox.zip", "Zip" );
    ADD_RESOURCE_LOCATION( "./Fonts", "FileSystem" );
 
    // This will be moved into the Wartbed class
    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
}

Running the App

An WARTBED application is a loop, preferably updated from a provided frame listener. If so, when resources are loaded, running is merely a question of engaging the auto pilot by invoking the mainLoop method:

wartbed.mainLoop();

The application will run until an event named "quit" event is encountered.

Shutting down

Send the message "quit" to the event manager. By default, a "quit" event is mapped to the ESCAPE button. Deallocation of all resources allocated within the framework or by using framework methods is taken care of automatically.

Personal tools
communication