Crazy Eddie's GUI System  ${CEGUI_VERSION}
CEGuiBaseApplication Class Referenceabstract

Base application abstract base class. More...

Inherited by CEGuiAndroidOpenglEs2BaseApplication, CEGuiD3D10BaseApplication, CEGuiD3D11BaseApplication, CEGuiD3D9BaseApplication, CEGuiDirectFBBaseApplication, CEGuiGLFWSharedBase, CEGuiIrrlichtBaseApplication, and CEGuiOgreBaseApplication.

+ Collaboration diagram for CEGuiBaseApplication:

Public Member Functions

 CEGuiBaseApplication ()
 Constructor.
 
virtual ~CEGuiBaseApplication ()
 Destructor.
 
virtual bool init (SamplesFrameworkBase *sampleApp, const CEGUI::String &logFile, const CEGUI::String &dataPathPrefixOverride)
 Initialise the base application. More...
 
virtual void cleanup ()
 Performs any required cleanup of the base application system. More...
 
virtual void destroyRenderer ()
 
void renderSingleFrame (const float elapsed)
 Render a single display frame. This should be called by subclasses to perform rendering. More...
 
bool isInitialised ()
 
CEGUI::String getDataPathPrefix () const
 Return the path prefix to use for datafiles. The value returned is obtained via a environment variable named 'CEGUI_SAMPLE_DATAPATH' if the variable is not set, a default will be used depending on the build system in use.
 
void initDataPathPrefix (const CEGUI::String &override)
 
void registerSampleOverlayHandler (CEGUI::GUIContext *gui_context)
 Registers the overlay handler for rendering the FPS for a specified GUIContext.
 
virtual void run ()
 The abstract function for running the application.
 

Protected Member Functions

virtual void destroyWindow ()=0
 The abstract function for destroying the renderer and the window.
 
virtual void beginRendering (const float elapsed)=0
 Implementation function to perform required pre-render operations.
 
virtual void endRendering ()=0
 Implementation function to perform required post-render operations.
 
virtual void initialiseResourceGroupDirectories (const CEGUI::String &dataPathPrefixOverride)
 Setup standard sample resource group directory locations. Default uses the CEGUI::DefaultResourceProvider - override if the sample base app being implemented uses something else!
 
virtual void initialiseDefaultResourceGroups ()
 initialise the standard default resource groups used by the samples.
 
void updateFPS (const float elapsed)
 function that updates the FPS rendering as needed.
 
void updateLogo (const float elapsed)
 function that updates the logo rotation as needed.
 
void positionLogo ()
 function that positions the logo in the correct place.
 
void positionFPS ()
 positions the FPS counter at the correct place.
 
bool sampleBrowserOverlayHandler (const CEGUI::EventArgs &args)
 event handler function that draws the logo and FPS overlay elements.
 
bool sampleOverlayHandler (const CEGUI::EventArgs &args)
 event handler function that draws the FPS overlay elements.
 
bool resizeHandler (const CEGUI::EventArgs &args)
 event handler function called when main view is resized
 

Protected Attributes

bool d_quitting
 true when the base app should cleanup and exit.
 
CEGUI::Rendererd_renderer
 Renderer to use. This MUST be set in the subclass constructor.
 
CEGUI::ImageCodecd_imageCodec
 ImageCodec to use. Set in subclass constructor, may be 0.
 
CEGUI::ResourceProviderd_resourceProvider
 ResourceProvider to use. Set in subclass constructor, may be 0.
 
CEGUI::GeometryBufferd_logoGeometry
 GeometryBuffer used for drawing the spinning CEGUI logo.
 
CEGUI::GeometryBufferd_FPSGeometry
 GeometryBuffer used for drawing the FPS value.
 
float d_FPSElapsed
 Fraction of second elapsed (used for counting frames per second).
 
int d_FPSFrames
 Number of frames drawn so far.
 
int d_FPSValue
 Last changed FPS value.
 
bool d_spinLogo
 whether to spin the logo
 

Static Protected Attributes

static const char DATAPATH_VAR_NAME [] = "CEGUI_SAMPLE_DATAPATH"
 name of env var that holds the path prefix to the data files.
 
static SamplesFrameworkBased_sampleApp
 SampleFramework base used in the application.
 
static const int s_defaultWindowWidth = 1280
 The window width the application should get created with at start.
 
static const int s_defaultWindowHeight = 720
 The window height the application should get created with at start.
 

Detailed Description

Base application abstract base class.

The "BaseApplication" family of classes are used to start up and run a host application for CeGui samples in a consistent manner.

Member Function Documentation

§ cleanup()

void CEGuiBaseApplication::cleanup ( void  )
virtual

Performs any required cleanup of the base application system.

Classes that override this method must, lastly, call the implementation of the superclass!

References d_FPSGeometry, d_logoGeometry, d_renderer, CEGUI::System::destroy(), CEGUI::Renderer::destroyGeometryBuffer(), destroyWindow(), and initialiseResourceGroupDirectories().

Referenced by SamplesFrameworkBase::initialise(), and SamplesFrameworkBase::~SamplesFrameworkBase().

§ init()

bool CEGuiBaseApplication::init ( SamplesFrameworkBase sampleApp,
const CEGUI::String logFile,
const CEGUI::String dataPathPrefixOverride 
)
virtual

Initialise the base application.

This will fully initialise the application, finish initialisation of the demo via calls to 'sampleApp', and finally control execution of the sample. This calls calls the virtual run function.

Classes that override this method must first call the implementation of the superclass!

Parameters
sampleAppPointer to the CEGuiSample object that the CEGuiBaseApplication is being invoked for.
Returns
  • true if the application initialised okay (cleanup function will be called).

Reimplemented in CEGuiOgreBaseApplication, and CEGuiAndroidOpenglEs2BaseApplication.

References CEGUI::RenderingSurface::clearGeometry(), CEGUI::System::create(), CEGUI::Renderer::createGeometryBuffer(), d_FPSGeometry, d_imageCodec, d_logoGeometry, d_renderer, d_resourceProvider, d_sampleApp, CEGUI::System::EventDisplaySizeChanged, CEGUI::RenderingSurface::EventRenderQueueStarted, CEGUI::Renderer::getDisplaySize(), CEGUI::Rect< T >::getHeight(), CEGUI::System::getSingleton(), CEGUI::Rect< T >::getWidth(), initialiseDefaultResourceGroups(), initialiseResourceGroupDirectories(), positionFPS(), positionLogo(), resizeHandler(), CEGUI::RQ_OVERLAY, sampleBrowserOverlayHandler(), SamplesFrameworkBase::setApplicationWindowSize(), CEGUI::GeometryBuffer::setClippingRegion(), CEGUI::GeometryBuffer::setPivot(), and CEGUI::EventSet::subscribeEvent().

Referenced by CEGuiAndroidOpenglEs2BaseApplication::init(), and SamplesFrameworkBase::initialise().

§ renderSingleFrame()

void CEGuiBaseApplication::renderSingleFrame ( const float  elapsed)

Render a single display frame. This should be called by subclasses to perform rendering.

This function handles all per-frame updates, calls beginRendering, then renders the CEGUI output, and finally calls endRendering.

Parameters
elapsedNumber of seconds elapsed since last frame.

References beginRendering(), CEGUI::Renderer::beginRendering(), CEGUI::WindowManager::cleanDeadPool(), d_sampleApp, endRendering(), CEGUI::System::getRenderer(), CEGUI::System::getSingleton(), CEGUI::System::injectTimePulse(), SamplesFrameworkBase::renderGUIContexts(), SamplesFrameworkBase::update(), updateFPS(), and updateLogo().

Referenced by SamplesFrameworkBase::initialise().