Crazy Eddie's GUI System  ${CEGUI_VERSION}
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 
37 // Frame listener forward ref (see class below)
39 // Window event listener forward ref (see class below)
40 class WndEvtListener;
41 
42 class CEGuiOgreBaseApplication : public CEGuiBaseApplication, public Ogre::FrameListener
43 {
44 public:
47 
50 
52  void doFrameUpdate(float elapsed);
53 
55  bool frameRenderingQueued(const Ogre::FrameEvent& evt);
56 
57  bool isInitialised();
58 
59 protected:
60  // override from base class since we use a non-default resource provider.
62 
63  // Implementation of base class abstract methods.
64  void run();
65  void destroyWindow();
66  void beginRendering(const float elapsed);
67  void endRendering();
68 
69  // We set up our Ogre default config to match our other renderer's default values if possible
70  // and if no config available already
71  void setupDefaultConfigIfNeeded();
72 
73  /*************************************************************************
74  Data Fields
75  *************************************************************************/
76  Ogre::Root* d_ogreRoot;
77  Ogre::Camera* d_camera;
78  Ogre::RenderWindow* d_window;
79  bool d_initialised;
80 
81  CEGuiDemoFrameListener* d_frameListener;
82  WndEvtListener* d_windowEventListener;
83 };
84 
85 
90 class CEGuiDemoFrameListener : public Ogre::FrameListener, public OIS::KeyListener, public OIS::MouseListener
91 {
92 public:
93  // Construction and Destruction
94  CEGuiDemoFrameListener(CEGuiOgreBaseApplication* baseApp, SamplesFrameworkBase*& sampleApp, Ogre::RenderWindow* win, Ogre::Camera* cam, bool useBufferedInputKeys = false, bool useBufferedInputMouse = false);
96 
97  // Processing to be done at start and end of each frame.
98  bool frameStarted(const Ogre::FrameEvent& evt);
99  bool frameEnded(const Ogre::FrameEvent& evt);
100 
101  // Raw input handlers that we care about
102  bool mouseMoved(const OIS::MouseEvent &e);
103  bool keyPressed(const OIS::KeyEvent &e);
104  bool keyReleased(const OIS::KeyEvent &e);
105  bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id);
106  bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id);
107 
108  OIS::Mouse* getOISMouse();
109 
110 protected:
111  // convert an OIS mouse button into a CEGUI mouse button
112  CEGUI::MouseButton convertOISButtonToCegui(int buttonID);
113 
114  /*************************************************************************
115  Data Fields
116  *************************************************************************/
117  OIS::InputManager* d_inputManager;
118  OIS::Keyboard* d_keyboard;
119  OIS::Mouse* d_mouse;
120  Ogre::Camera* d_camera;
121  Ogre::RenderWindow* d_window;
122 
123  CEGuiOgreBaseApplication* d_baseApp;
124  SamplesFrameworkBase*& d_sampleApp;
125 };
126 
128 class WndEvtListener : public Ogre::WindowEventListener
129 {
130 public:
131  WndEvtListener(OIS::Mouse* mouse);
132 
133  void windowResized(Ogre::RenderWindow* rw);
134 protected:
135  OIS::Mouse* d_mouse;
136 };
137 
138 
139 #endif // end of guard _CEGuiOgreBaseApplication_h_
Ogre FrameListener class where we deal with input processing and the like.
Definition: CEGuiOgreBaseApplication.h:90
void initialiseResourceGroupDirectories()
Setup standard sample resource group directory locations. Default uses the CEGUI::DefaultResourceProv...
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.
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
Base application abstract base class.
Definition: CEGuiBaseApplication.h:67
void destroyWindow()
The abstract function for destroying the renderer and the window.
void run()
The abstract function for initialising and running the application.
~CEGuiOgreBaseApplication()
Destructor.
window event listener class we use to hear abour window resizing
Definition: CEGuiOgreBaseApplication.h:128
Definition: CEGuiOgreBaseApplication.h:42
Definition: python_CEGUIOgreRenderer.h:13