Crazy Eddie's GUI System  ${CEGUI_VERSION}
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
CEGuiOgreBaseApplication.h
1 /***********************************************************************
2  created: 9/3/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 _CEGuiOgreBaseApplication_h_
28 #define _CEGuiOgreBaseApplication_h_
29 
30 #include "CEGuiBaseApplication.h"
31 #include "CEGUI/CEGUI.h"
32 
33 #include "CEGUI/RendererModules/Ogre/Renderer.h"
34 #include <Ogre.h>
35 #include <OIS.h>
36 #include <OgreFrameListener.h>
37 
38 #include <OgreBuildSettings.h>
39 #ifdef OGRE_STATIC_LIB
40 # ifdef OGRE_BUILD_RENDERSYSTEM_D3D9
41 # define OGRE_STATIC_Direct3D9
42 # endif
43 # ifdef OGRE_BUILD_RENDERSYSTEM_D3D11
44 # define OGRE_STATIC_Direct3D11
45 # endif
46 # ifdef OGRE_BUILD_RENDERSYSTEM_GL
47 # define OGRE_STATIC_GL
48 # endif
49 # ifdef OGRE_BUILD_RENDERSYSTEM_GL3PLUS
50 # define OGRE_STATIC_GL3Plus
51 # endif
52 # ifdef OGRE_BUILD_RENDERSYSTEM_GLES
53 # define OGRE_STATIC_GLES
54 # endif
55 # ifdef OGRE_BUILD_RENDERSYSTEM_GLES2
56 # define OGRE_STATIC_GLES2
57 # endif
58 # include <OgreStaticPluginLoader.h>
59 #endif
60 
61 // Frame listener forward ref (see class below)
63 // Window event listener forward ref (see class below)
64 class WndEvtListener;
65 
66 class CEGuiOgreBaseApplication : public CEGuiBaseApplication, public Ogre::FrameListener
67 {
68 public:
71 
74 
75  bool init(SamplesFrameworkBase* sampleApp, const CEGUI::String &logFile,
76  const CEGUI::String &dataPathPrefixOverride);
77 
78  void destroyRenderer();
79 
81  void doFrameUpdate(float elapsed);
82 
84  bool frameRenderingQueued(const Ogre::FrameEvent& evt);
85 
86  bool isInitialised();
87 
88 protected:
89  // override from base class since we use a non-default resource provider.
90  void initialiseResourceGroupDirectories();
91 
92  // Implementation of base class abstract methods.
93  void destroyWindow();
94  void beginRendering(const float elapsed);
95  void endRendering();
96 
97  // We set up our Ogre default config to match our other renderer's default values if possible
98  // and if no config available already
99  void setupDefaultConfigIfNeeded();
100 
101  /*************************************************************************
102  Data Fields
103  *************************************************************************/
104  Ogre::Root* d_ogreRoot;
105  Ogre::Camera* d_camera;
106  Ogre::RenderWindow* d_window;
107  bool d_initialised;
108 #ifdef OGRE_STATIC_LIB
109  Ogre::StaticPluginLoader* d_staticPluginLoader;
110 #endif
111 
112  CEGuiDemoFrameListener* d_frameListener;
113  WndEvtListener* d_windowEventListener;
114 };
115 
120 class CEGuiDemoFrameListener : public Ogre::FrameListener, public OIS::KeyListener, public OIS::MouseListener
121 {
122 public:
123  // Construction and Destruction
124  CEGuiDemoFrameListener(CEGuiOgreBaseApplication* baseApp, SamplesFrameworkBase*& sampleApp, Ogre::RenderWindow* win, Ogre::Camera* cam);
126 
127  // Processing to be done at start and end of each frame.
128  bool frameStarted(const Ogre::FrameEvent& evt);
129  bool frameEnded(const Ogre::FrameEvent& evt);
130 
131  // Raw input handlers that we care about
132  bool mouseMoved(const OIS::MouseEvent &e);
133  bool keyPressed(const OIS::KeyEvent &e);
134  bool keyReleased(const OIS::KeyEvent &e);
135  bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id);
136  bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id);
137 
138  OIS::Mouse* getOISMouse();
139 
140 protected:
141  // convert an OIS mouse button into a CEGUI mouse button
142  CEGUI::MouseButton convertOISButtonToCegui(int buttonID);
143 
144  /*************************************************************************
145  Data Fields
146  *************************************************************************/
147  OIS::InputManager* d_inputManager;
148  OIS::Keyboard* d_keyboard;
149  OIS::Mouse* d_mouse;
150  Ogre::Camera* d_camera;
151  Ogre::RenderWindow* d_window;
152 
153  CEGuiOgreBaseApplication* d_baseApp;
154  SamplesFrameworkBase*& d_sampleApp;
155 };
156 
158 class WndEvtListener : public Ogre::WindowEventListener
159 {
160 public:
161  WndEvtListener(OIS::Mouse* mouse);
162 
163  void windowResized(Ogre::RenderWindow* rw);
164 protected:
165  OIS::Mouse* d_mouse;
166 };
167 
168 
169 #endif // end of guard _CEGuiOgreBaseApplication_h_
Ogre FrameListener class where we deal with input processing and the like.
Definition: CEGuiOgreBaseApplication.h:120
CEGuiOgreBaseApplication()
Constructor.
void endRendering()
Implementation function to perform required post-render operations.
MouseButton
Enumeration of mouse buttons.
Definition: cegui/include/CEGUI/InputEvent.h:209
void beginRendering(const float elapsed)
Implementation function to perform required pre-render operations.
bool frameRenderingQueued(const Ogre::FrameEvent &evt)
Ogre frame listener callback that will trigger our specific context rendering.
void doFrameUpdate(float elapsed)
called by the frame listener to perform requried per-frame updates.
bool init(SamplesFrameworkBase *sampleApp, const CEGUI::String &logFile, const CEGUI::String &dataPathPrefixOverride)
Initialise the base application.
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
void destroyWindow()
The abstract function for destroying the renderer and the window.
~CEGuiOgreBaseApplication()
Destructor.
window event listener class we use to hear abour window resizing
Definition: CEGuiOgreBaseApplication.h:158
Definition: CEGuiOgreBaseApplication.h:66
Definition: python_CEGUIOgreRenderer.h:13
String class used within the GUI system.
Definition: cegui/include/CEGUI/String.h:62