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 #include "CEGUI/String.h"
31 
32 // If this looks wanky, it's becase it is! Behold that this is not as fullblown
33 // as it could be though.
34 #ifndef PATH_MAX
35 # include <stdlib.h>
36 # ifndef PATH_MAX
37 # include <limits.h>
38 # endif
39 # ifndef PATH_MAX
40 # ifdef _MAX_PATH
41 # define PATH_MAX _MAX_PATH
42 # else
43 # define PATH_MAX 260
44 # endif
45 # endif
46 #endif
47 
48 /*************************************************************************
49  Forward refs
50 *************************************************************************/
52 namespace CEGUI
53 {
54 class Renderer;
55 class ImageCodec;
56 class ResourceProvider;
57 class GeometryBuffer;
58 class EventArgs;
59 class GUIContext;
60 }
61 
70 {
71 public:
74 
76  virtual ~CEGuiBaseApplication();
77 
97  virtual bool init(SamplesFrameworkBase* sampleApp,
98  const CEGUI::String& logFile,
99  const CEGUI::String& dataPathPrefixOverride);
100 
108  virtual void cleanup();
109 
110  virtual void destroyRenderer();
111 
123  void renderSingleFrame(const float elapsed);
124 
125  /* Returns if the renderer (DX or OpenGL) was selected and the initialisation
126  was subsequently finished */
127  bool isInitialised();
128 
136  CEGUI::String getDataPathPrefix() const { return d_dataPathPrefix; }
137 
138  void initDataPathPrefix(const CEGUI::String &override);
139 
144  void registerSampleOverlayHandler(CEGUI::GUIContext* gui_context);
145 
147  virtual void run() {}
148 
149 protected:
151  static const char DATAPATH_VAR_NAME[];
152 
154  virtual void destroyWindow() = 0;
156  virtual void beginRendering(const float elapsed) = 0;
158  virtual void endRendering() = 0;
159 
166  virtual void initialiseResourceGroupDirectories
167  (const CEGUI::String& dataPathPrefixOverride);
168 
170  virtual void initialiseDefaultResourceGroups();
171 
173  void updateFPS(const float elapsed);
175  void updateLogo(const float elapsed);
177  void positionLogo();
179  void positionFPS();
181  bool sampleBrowserOverlayHandler(const CEGUI::EventArgs& args);
183  bool sampleOverlayHandler(const CEGUI::EventArgs& args);
185  bool resizeHandler(const CEGUI::EventArgs& args);
186 
190  static const int s_defaultWindowWidth = 1280;
192  static const int s_defaultWindowHeight = 720;
193 
214 
215 private:
216  CEGUI::String d_dataPathPrefix;
217 
218 };
219 
220 #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:188
CEGUI::Renderer * d_renderer
Renderer to use. This MUST be set in the subclass constructor.
Definition: CEGuiBaseApplication.h:197
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&#39;s GUI Library.
Definition: cegui/include/CEGUI/Affector.h:42
Base class used as the argument to all subscribers Event object.
Definition: cegui/include/CEGUI/EventArgs.h:49
virtual void run()
The abstract function for running the application.
Definition: CEGuiBaseApplication.h:147
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: cegui/include/CEGUI/GeometryBuffer.h:42
int d_FPSValue
Last changed FPS value.
Definition: CEGuiBaseApplication.h:211
int d_FPSFrames
Number of frames drawn so far.
Definition: CEGuiBaseApplication.h:209
CEGUI::ResourceProvider * d_resourceProvider
ResourceProvider to use. Set in subclass constructor, may be 0.
Definition: CEGuiBaseApplication.h:201
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:199
This is a base class that is intended to be used for all sample applications. Here we take care of co...
Definition: SamplesFrameworkBase.h:43
Base application abstract base class.
Definition: CEGuiBaseApplication.h:69
CEGUI::GeometryBuffer * d_logoGeometry
GeometryBuffer used for drawing the spinning CEGUI logo.
Definition: CEGuiBaseApplication.h:203
bool d_spinLogo
whether to spin the logo
Definition: CEGuiBaseApplication.h:213
bool d_quitting
true when the base app should cleanup and exit.
Definition: CEGuiBaseApplication.h:195
CEGUI::String getDataPathPrefix() const
Return the path prefix to use for datafiles. The value returned is obtained via a environment variabl...
Definition: CEGuiBaseApplication.h:136
float d_FPSElapsed
Fraction of second elapsed (used for counting frames per second).
Definition: CEGuiBaseApplication.h:207
CEGUI::GeometryBuffer * d_FPSGeometry
GeometryBuffer used for drawing the FPS value.
Definition: CEGuiBaseApplication.h:205
String class used within the GUI system.
Definition: cegui/include/CEGUI/String.h:62