CrystalSpace

Public API Reference

CS::Utility::DemoApplication Class Reference

Crystal Space demo application framework class. More...

#include <cstool/demoapplication.h>

Inheritance diagram for CS::Utility::DemoApplication:

List of all members.

Public Member Functions

virtual bool Application ()
 Base implementation of the method inherited from csApplicationFramework.
 DemoApplication (const char *applicationName)
 Constructor.
virtual void OnExit ()
 Base implementation of the method inherited from csApplicationFramework.
virtual bool OnInitialize (int argc, char *argv[])
 Base implementation of the method inherited from csApplicationFramework.

Protected Member Functions

virtual bool CreateRoom ()
 Default initialization for the creation of the main sector (DemoApplication::room).
virtual void Frame ()
 Base implementation of the method inherited from csBaseEventHandler.
virtual const char * GetApplicationConfigFile ()
 Return VFS path of an additional config file to load at initialization Override this if you wish to use an application-specific config file on top of demoapplication.cfg.
virtual bool OnKeyboard (iEvent &event)
 Base implementation of the method inherited from csBaseEventHandler.
virtual bool OnMouseMove (iEvent &event)
 Base implementation of the method inherited from csBaseEventHandler.
virtual void PrintHelp ()
 Print the help message for this application on standard output.

Protected Attributes

csRef
< CS::Utility::iCameraManager
cameraManager
 Reference to the default camera manager.
csRef< iCommandLineParserclp
 Reference to the command line parser.
csConfigAccess config
 Access to the configuration manager system.
csRef< iEngineengine
 Reference to the engine.
csRef< iGraphics2Dg2d
 Reference to the 2D graphics.
csRef< iGraphics3Dg3d
 Reference to the 3D graphics.
csRef< CS::Utility::iHUDManagerhudManager
 Reference to the default HUD manager.
csRef< iKeyboardDriverkbd
 Reference to the keyboard driver.
csRef< iLoaderloader
 Reference to the loader.
csRef< iMouseDrivermouse
 Reference to the mouse driver.
csRef< iNativeWindownatwin
 Reference to the native window.
csVector2 previousMouse
 Previous position of the mouse cursor during the last frame.
csRef< FramePrinterprinter
 Reference to the frame printer.
csRef< iSectorroom
 Reference to the main sector.
csRef< iVirtualClockvc
 Reference to the virtual clock.
csRef< iVFSvfs
 Reference to the virtual file system.
csRef< iViewview
 Reference to the view.
csRef< CS::Debug::iVisualDebuggervisualDebugger
 Visual debugger.

Detailed Description

Crystal Space demo application framework class.

This class and its companions provide the basic functionalities for Crystal Space's demo and test applications. Most demos, tests and tutorials would want to use this class in order to simplify their code, make it more pertinent for the user, and unify the graphical and general layout between all applications.

The functionalities provided by this class are:

Here is an example for the most simple use of this class:

 //--------------------------
 // example.h

 #include "cstool/csdemoapplication.h"

 class MyApp : public CS::Utility::DemoApplication
 {
 public:
   MyApp();
   bool Application ();
 };

 //--------------------------
 // example.cpp

 #include "cssysdef.h"
 #include "example.h"

 MyApp::MyApp ()
   : DemoApplication ("CrystalSpace.MyApp", "myapplication", "myapplication",
                          "Description of 'myapplication'.")
 {
   // Configure the options for DemoApplication
 }

 bool MyApp::Application ()
 {
   // Default behavior from DemoApplication
   if (!DemoApplication::Application ())
     return false;

   // Initialize here your application

   // Default behavior from DemoApplication for the creation of the scene
   if (!CreateRoom ())
     return false;

   // Create here the main objects of your scene

   // Run the application
   Run();

   return true;
 }

 //--------------------------
 // main.cpp

 #include "cssysdef.h"
 #include "example.h"

 CS_IMPLEMENT_APPLICATION
 
 int main (int argc, char* argv[]) 
 {
   return MyApp ().Main (argc, argv);
 }
See also:
CS::Utility::iCameraManager CS::Utility::iHUDManager

Definition at line 143 of file demoapplication.h.


Constructor & Destructor Documentation

CS::Utility::DemoApplication::DemoApplication ( const char *  applicationName  ) 

Constructor.

Parameters:
applicationName Name of the application, used to set csApplicationFramework::SetApplicationName().

Member Function Documentation

virtual bool CS::Utility::DemoApplication::Application (  )  [virtual]

Base implementation of the method inherited from csApplicationFramework.

It opens the main application, find references to the engine objects, creates the main view used for rendering, and initializes the HUD manager.

Implements csApplicationFramework.

virtual bool CS::Utility::DemoApplication::CreateRoom (  )  [protected, virtual]

Default initialization for the creation of the main sector (DemoApplication::room).

It creates a sector of name "room", adds a grey uniform background far away, initializes the camera and add some lights.

virtual void CS::Utility::DemoApplication::Frame (  )  [protected, virtual]

Base implementation of the method inherited from csBaseEventHandler.

It initializes the previous position of the mouse cursor, renders the view and displays the visual debugging information if any.

Reimplemented from csBaseEventHandler.

virtual const char* CS::Utility::DemoApplication::GetApplicationConfigFile (  )  [inline, protected, virtual]

Return VFS path of an additional config file to load at initialization Override this if you wish to use an application-specific config file on top of demoapplication.cfg.

Definition at line 240 of file demoapplication.h.

virtual void CS::Utility::DemoApplication::OnExit (  )  [virtual]

Base implementation of the method inherited from csApplicationFramework.

It closes the frame printer.

Reimplemented from csApplicationFramework.

virtual bool CS::Utility::DemoApplication::OnInitialize ( int  argc,
char *  argv[] 
) [virtual]

Base implementation of the method inherited from csApplicationFramework.

It loads all base plugins, and registers itself to the event queue.

Implements csApplicationFramework.

virtual bool CS::Utility::DemoApplication::OnKeyboard ( iEvent event  )  [protected, virtual]

Base implementation of the method inherited from csBaseEventHandler.

It checks for the "Help" or "Esc" keys.

Reimplemented from csBaseEventHandler.

virtual bool CS::Utility::DemoApplication::OnMouseMove ( iEvent event  )  [protected, virtual]

Base implementation of the method inherited from csBaseEventHandler.

It simply updates the previousMouse position.

Reimplemented from csBaseEventHandler.

virtual void CS::Utility::DemoApplication::PrintHelp (  )  [protected, virtual]

Print the help message for this application on standard output.

You may need to implement this method in order to print out the commanline options of your application.


Member Data Documentation

Reference to the default camera manager.

Definition at line 193 of file demoapplication.h.

Reference to the command line parser.

Definition at line 180 of file demoapplication.h.

Access to the configuration manager system.

Definition at line 200 of file demoapplication.h.

Reference to the engine.

Definition at line 158 of file demoapplication.h.

Reference to the 2D graphics.

Definition at line 164 of file demoapplication.h.

Reference to the 3D graphics.

Definition at line 162 of file demoapplication.h.

Reference to the default HUD manager.

Definition at line 190 of file demoapplication.h.

Reference to the keyboard driver.

Definition at line 168 of file demoapplication.h.

Reference to the loader.

Definition at line 160 of file demoapplication.h.

Reference to the mouse driver.

Definition at line 178 of file demoapplication.h.

Reference to the native window.

Definition at line 166 of file demoapplication.h.

Previous position of the mouse cursor during the last frame.

It can be used to know the distance travelled by comparing it to "mouse->GetLastX/Y".

Definition at line 184 of file demoapplication.h.

Reference to the frame printer.

Definition at line 174 of file demoapplication.h.

Reference to the main sector.

Definition at line 187 of file demoapplication.h.

Reference to the virtual clock.

Definition at line 170 of file demoapplication.h.

Reference to the virtual file system.

Definition at line 176 of file demoapplication.h.

Reference to the view.

Definition at line 172 of file demoapplication.h.

Visual debugger.

Definition at line 197 of file demoapplication.h.


The documentation for this class was generated from the following file:

Generated for Crystal Space 2.1 by doxygen 1.6.1