GG::OgreGUI Class Reference

This is an abstract singleton class that represents the GUI framework of an Ogre OpenGL application. More...

#include <OgreGUI.h>

Inheritance diagram for GG::OgreGUI:

GG::GUI List of all members.

Public Member Functions

 OgreGUI (Ogre::RenderWindow *window, const std::string &config_filename="")
virtual ~OgreGUI ()
virtual boost::shared_ptr<
ModalEventPump
CreateModalEventPump (bool &done)
virtual int Ticks () const
virtual int AppWidth () const
virtual int AppHeight () const
const Ogre::SharedPtr< Ogre::DataStream > & ConfigFileStream () const
virtual void Exit (int code)

Static Public Member Functions

static OgreGUIGetGUI ()

Public Attributes

boost::signal< void()> HandleSystemEventsSignal
boost::signal< void(int, int)> WindowResizedSignal
boost::signal< void()> WindowClosedSignal

Protected Member Functions

virtual void RenderBegin ()
virtual void RenderEnd ()
virtual void Run ()
virtual void HandleSystemEvents ()
virtual void Enter2DMode ()
virtual void Exit2DMode ()

Detailed Description

This is an abstract singleton class that represents the GUI framework of an Ogre OpenGL application.

Usage:
Any application including an object of this class should declare that object as a local variable in main(). The name of this variable will herein be assumed to be "gui". It should be allocated on the stack; if it is created dynamically, a leak may occur.

OgreGUI serves as a driver of the main Ogre event loop, and mediates between the global GL state set by Ogre and the global GL state set by GG. It also provides important information to the input plugin via its public signals.

OgreGUI does not constitute a complete input driver for GG. This is because Ogre does not provide any direct input support at all (at the time of this writing, Ogre uses an input library called OIS to provide keyboard, mouse, and joystick input). Following the Ogre convention, OgreGUI relies upon the Ogre plugin system to provide the actual input system used by Ogre and GG. A plugin for OIS is provided in the Ogre/Plugins subtree of the GG sources.

Any plugin used with OgreGUI must grab input state (mouse, keyboard, etc.) in response to the firing of OgreGUI::HandleSystemEventsSignal. It is notified of changes in the window size via OgreGUI::WindowResizedSignal. OgreGUI::HandleWindowClose indicates that the Ogre::RenderWindow in which OgreGUI is operating has or is about to close, in case the plugin needs to perform cleanup.

To use OgreGUI, one must first create "gui", then load the input plugin using Ogre's plugin loading mechanism, then call "gui();". For example:

    OgreGUI gui(ogre_window, "/path/to/input_plugin.cfg");
    ogre_root->loadPlugin("/path/to/plugin");
    gui();
    

Definition at line 92 of file OgreGUI.h.


Constructor & Destructor Documentation

GG::OgreGUI::OgreGUI ( Ogre::RenderWindow *  window,
const std::string &  config_filename = "" 
) [explicit]

Basic ctor.

A nonzero window is required, and an optional configuration filename, config_filename. If config_filename is supplied, it will be available via ConfigFileStream().

virtual GG::OgreGUI::~OgreGUI (  )  [virtual]

Dtor.


Member Function Documentation

virtual boost::shared_ptr<ModalEventPump> GG::OgreGUI::CreateModalEventPump ( bool &  done  )  [virtual]

Creates a modal event pump suitable for use with Ogre.

Reimplemented from GG::GUI.

virtual int GG::OgreGUI::Ticks (  )  const [virtual]

returns ms since the app started running

Implements GG::GUI.

virtual int GG::OgreGUI::AppWidth (  )  const [virtual]

returns the width of the application window/screen

Implements GG::GUI.

virtual int GG::OgreGUI::AppHeight (  )  const [virtual]

returns the height of the application window/screen

Implements GG::GUI.

const Ogre::SharedPtr<Ogre::DataStream>& GG::OgreGUI::ConfigFileStream (  )  const

Returns an Ogre::DataStream containing the contents of the config_filename ctor parameter.

This will be null if config_filename was not supplied to the ctor.

virtual void GG::OgreGUI::Exit ( int  code  )  [virtual]

does basic clean-up, then calls exit(); callable from anywhere in user code via GetGUI()

Implements GG::GUI.

static OgreGUI* GG::OgreGUI::GetGUI (  )  [static]

Allows any code to access the gui framework by calling GG::OgreGUI::GetGUI().

Reimplemented from GG::GUI.

virtual void GG::OgreGUI::RenderBegin (  )  [protected, virtual]

clears the backbuffer, etc.

Implements GG::GUI.

virtual void GG::OgreGUI::RenderEnd (  )  [protected, virtual]

swaps buffers, etc.

Implements GG::GUI.

virtual void GG::OgreGUI::Run (  )  [protected, virtual]

initializes GUI state, then executes main event handler/render loop (PollAndRender())

Implements GG::GUI.

virtual void GG::OgreGUI::HandleSystemEvents (  )  [protected, virtual]

handles all waiting system events (from SDL, DirectInput, etc.

). This function should only be called from custom EventPump event handlers.

Implements GG::GUI.

virtual void GG::OgreGUI::Enter2DMode (  )  [protected, virtual]

saves any current GL state, sets up GG-friendly 2D drawing mode. GG expects an orthographic projection, with the origin in the upper left corner, and with one unit of GL space equal to one pixel on the screen.

Implements GG::GUI.

virtual void GG::OgreGUI::Exit2DMode (  )  [protected, virtual]

restores GL to its condition prior to Enter2DMode() call

Implements GG::GUI.


Member Data Documentation

boost::signal<void ()> GG::OgreGUI::HandleSystemEventsSignal

Emitted whenever the OgreGUI is ready for human input from the keyboard, mouse, etc.

Definition at line 122 of file OgreGUI.h.

boost::signal<void (int, int)> GG::OgreGUI::WindowResizedSignal

Emitted whenever the OgreGUI's AppWidth() and/or AppHeight() change.

Definition at line 125 of file OgreGUI.h.

boost::signal<void ()> GG::OgreGUI::WindowClosedSignal

Emitted when the Ogre::RenderWindow in which the OgreGUI is operating closes or is about to close.

Definition at line 129 of file OgreGUI.h.


The documentation for this class was generated from the following file:
Generated on Wed Mar 26 14:35:42 2008 for GG by  doxygen 1.5.2