Crazy Eddie's GUI System  ${CEGUI_VERSION}
CEGuiBaseApplication.h
1 /***********************************************************************
2  created: 24/9/2004
3  author: Paul D Turner
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _CEGuiBaseApplication_h_
28 #define _CEGuiBaseApplication_h_
29 
30 // If this looks wanky, it's becase it is! Behold that this is not as fullblown
31 // as it could be though.
32 #ifndef PATH_MAX
33 # include <stdlib.h>
34 # ifndef PATH_MAX
35 # include <limits.h>
36 # endif
37 # ifndef PATH_MAX
38 # ifdef _MAX_PATH
39 # define PATH_MAX _MAX_PATH
40 # else
41 # define PATH_MAX 260
42 # endif
43 # endif
44 #endif
45 
46 /*************************************************************************
47  Forward refs
48 *************************************************************************/
50 namespace CEGUI
51 {
52 class Renderer;
53 class ImageCodec;
54 class ResourceProvider;
55 class GeometryBuffer;
56 class EventArgs;
57 class GUIContext;
58 }
59 
68 {
69 public:
72 
74  virtual ~CEGuiBaseApplication();
75 
94  bool execute(SamplesFrameworkBase* sampleApp);
95 
100  void cleanup();
101 
113  void renderSingleFrame(const float elapsed);
114 
115  /* Returns if the renderer (DX or OpenGL) was selected and the initialisation
116  was subsequently finished */
117  bool isInitialised();
118 
126  const char* getDataPathPrefix() const;
127 
133 
134 
135 protected:
137  static const char DATAPATH_VAR_NAME[];
138 
140  virtual void run() = 0;
142  virtual void destroyWindow() = 0;
144  virtual void beginRendering(const float elapsed) = 0;
146  virtual void endRendering() = 0;
147 
154  virtual void initialiseResourceGroupDirectories();
155 
157  virtual void initialiseDefaultResourceGroups();
158 
160  void updateFPS(const float elapsed);
162  void updateLogo(const float elapsed);
164  void positionLogo();
166  void positionFPS();
170  bool sampleOverlayHandler(const CEGUI::EventArgs& args);
172  bool resizeHandler(const CEGUI::EventArgs& args);
173 
177  static const int s_defaultWindowWidth = 1280;
179  static const int s_defaultWindowHeight = 720;
180 
201 };
202 
203 #endif // end of guard _CEGuiBaseApplication_h_
Abstract ImageLoader class. An image loader encapsulate the loading of a texture. ...
Definition: cegui/include/CEGUI/ImageCodec.h:45
Definition: cegui/include/CEGUI/GUIContext.h:68
static SamplesFrameworkBase * d_sampleApp
SampleFramework base used in the application.
Definition: CEGuiBaseApplication.h:175
CEGUI::Renderer * d_renderer
Renderer to use. This MUST be set in the subclass constructor.
Definition: CEGuiBaseApplication.h:184
Abstract class that defines the required interface for all resource provider sub-classes.
Definition: cegui/include/CEGUI/ResourceProvider.h:47
Main namespace for Crazy Eddie's GUI Library.
Definition: cegui/include/CEGUI/Affector.h:42
virtual void run()=0
The abstract function for initialising and running the application.
virtual ~CEGuiBaseApplication()
Destructor.
Definition: CEGuiBaseApplication.cpp:80
Base class used as the argument to all subscribers Event object.
Definition: cegui/include/CEGUI/EventArgs.h:49
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: cegui/include/CEGUI/GeometryBuffer.h:42
CEGuiBaseApplication()
Constructor.
Definition: CEGuiBaseApplication.cpp:65
int d_FPSValue
Last changed FPS value.
Definition: CEGuiBaseApplication.h:198
const char * getDataPathPrefix() const
Return the path prefix to use for datafiles. The value returned is obtained via a environment variabl...
Definition: CEGuiBaseApplication.cpp:228
int d_FPSFrames
Number of frames drawn so far.
Definition: CEGuiBaseApplication.h:196
CEGUI::ResourceProvider * d_resourceProvider
ResourceProvider to use. Set in subclass constructor, may be 0.
Definition: CEGuiBaseApplication.h:188
void updateFPS(const float elapsed)
function that updates the FPS rendering as needed.
Definition: CEGuiBaseApplication.cpp:286
virtual void destroyWindow()=0
The abstract function for destroying the renderer and the window.
virtual void initialiseDefaultResourceGroups()
initialise the standard default resource groups used by the samples.
Definition: CEGuiBaseApplication.cpp:210
void cleanup()
Performs any required cleanup of the base application system.
Definition: CEGuiBaseApplication.cpp:171
virtual void initialiseResourceGroupDirectories()
Setup standard sample resource group directory locations. Default uses the CEGUI::DefaultResourceProv...
Definition: CEGuiBaseApplication.cpp:180
void registerSampleOverlayHandler(CEGUI::GUIContext *gui_context)
Registers the overlay handler for rendering the FPS for a specified GUIContext.
Definition: CEGuiBaseApplication.cpp:368
Abstract class defining the basic required interface for Renderer objects.
Definition: cegui/include/CEGUI/Renderer.h:82
CEGUI::ImageCodec * d_imageCodec
ImageCodec to use. Set in subclass constructor, may be 0.
Definition: CEGuiBaseApplication.h:186
This is a base class that is intended to be used for all sample applications. Here we take care of co...
Definition: SamplesFrameworkBase.h:42
void positionFPS()
positions the FPS counter at the correct place.
Definition: CEGuiBaseApplication.cpp:341
Base application abstract base class.
Definition: CEGuiBaseApplication.h:67
static const char DATAPATH_VAR_NAME[]
name of env var that holds the path prefix to the data files.
Definition: CEGuiBaseApplication.h:137
static const int s_defaultWindowHeight
The window height the application should get created with at start.
Definition: CEGuiBaseApplication.h:179
static const int s_defaultWindowWidth
The window width the application should get created with at start.
Definition: CEGuiBaseApplication.h:177
bool execute(SamplesFrameworkBase *sampleApp)
Start the base application.
Definition: CEGuiBaseApplication.cpp:109
virtual void endRendering()=0
Implementation function to perform required post-render operations.
void renderSingleFrame(const float elapsed)
Render a single display frame. This should be called by subclasses to perform rendering.
Definition: CEGuiBaseApplication.cpp:85
CEGUI::GeometryBuffer * d_logoGeometry
GeometryBuffer used for drawing the spinning CEGUI logo.
Definition: CEGuiBaseApplication.h:190
bool resizeHandler(const CEGUI::EventArgs &args)
event handler function called when main view is resized
Definition: CEGuiBaseApplication.cpp:352
bool d_spinLogo
whether to spin the logo
Definition: CEGuiBaseApplication.h:200
bool d_quitting
true when the base app should cleanup and exit.
Definition: CEGuiBaseApplication.h:182
void positionLogo()
function that positions the logo in the correct place.
Definition: CEGuiBaseApplication.cpp:331
float d_FPSElapsed
Fraction of second elapsed (used for counting frames per second).
Definition: CEGuiBaseApplication.h:194
bool sampleOverlayHandler(const CEGUI::EventArgs &args)
event handler function that draws the FPS overlay elements.
Definition: CEGuiBaseApplication.cpp:274
void updateLogo(const float elapsed)
function that updates the logo rotation as needed.
Definition: CEGuiBaseApplication.cpp:319
CEGUI::GeometryBuffer * d_FPSGeometry
GeometryBuffer used for drawing the FPS value.
Definition: CEGuiBaseApplication.h:192
virtual void beginRendering(const float elapsed)=0
Implementation function to perform required pre-render operations.
bool sampleBrowserOverlayHandler(const CEGUI::EventArgs &args)
event handler function that draws the logo and FPS overlay elements.
Definition: CEGuiBaseApplication.cpp:260