GG
OgreGUI.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /* GG is a GUI for SDL and OpenGL.
3  Copyright (C) 2007 T. Zachary Laine
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public License
7  as published by the Free Software Foundation; either version 2.1
8  of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free
17  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18  02111-1307 USA
19 
20  If you do not wish to comply with the terms of the LGPL please
21  contact the author as other terms are available for a fee.
22 
23  Zach Laine
24  whatwasthataddress@gmail.com */
25 
29 #ifndef _GG_OgreGUI_h_
30 #define _GG_OgreGUI_h_
31 
32 #ifdef __APPLE__
33 /* prevents OpenTransportProviders.h (a system header in Mac SDKs)
34  from trying to enum what's already defined by related headers */
35 #undef TCP_NODELAY
36 #undef TCP_MAXSEG
37 #undef TCP_NOTIFY_THRESHOLD
38 #undef TCP_ABORT_THRESHOLD
39 #undef TCP_CONN_NOTIFY_THRESHOLD
40 #undef TCP_CONN_ABORT_THRESHOLD
41 #undef TCP_OOBINLINE
42 #undef TCP_URGENT_PTR_TYPE
43 #undef TCP_KEEPALIVE
44 #include <Carbon/Carbon.h>
45 #endif
46 
47 #include <OgreDataStream.h>
48 #include <OgreRenderTargetListener.h>
49 #include <OgreSharedPtr.h>
50 #include <OgreTimer.h>
51 #include <OgreWindowEventUtilities.h>
52 
53 #include <GG/GUI.h>
54 
55 
56 #ifdef _MSC_VER
57 # ifdef GiGiOgre_EXPORTS
58 # define GG_OGRE_API __declspec(dllexport)
59 # else
60 # define GG_OGRE_API __declspec(dllimport)
61 # endif
62 #else
63 # define GG_OGRE_API
64 #endif
65 
66 namespace Ogre {
67  class RenderWindow;
68 }
69 
70 namespace GG {
71 
123 class GG_OGRE_API OgreGUI :
124  public GUI,
125  public Ogre::RenderTargetListener,
126  public Ogre::WindowEventListener
127 {
128 public:
132  explicit OgreGUI(Ogre::RenderWindow* window, const std::string& config_filename = "");
133 
135  virtual ~OgreGUI();
136 
138  virtual boost::shared_ptr<ModalEventPump> CreateModalEventPump(bool& done);
139 
140  virtual unsigned int Ticks() const;
141  virtual X AppWidth() const;
142  virtual Y AppHeight() const;
143 
147  const Ogre::SharedPtr<Ogre::DataStream>& ConfigFileStream() const;
148 
149  virtual void Exit(int code);
150 
153  boost::signal<void ()> HandleSystemEventsSignal;
154 
156  boost::signal<void (X, Y)> WindowResizedSignal;
157 
160  boost::signal<void ()> WindowClosedSignal;
161 
163  static OgreGUI* GetGUI();
164 
165 protected:
166  virtual void RenderBegin();
167  virtual void RenderEnd();
168  virtual void Run();
169  virtual void HandleSystemEvents();
170  virtual void Enter2DMode();
171  virtual void Exit2DMode();
172 
173 private:
174  virtual void postRenderTargetUpdate(const Ogre::RenderTargetEvent& event);
175  virtual void windowResized(Ogre::RenderWindow* window);
176  virtual void windowClosed(Ogre::RenderWindow* window);
177 
178  Ogre::RenderWindow* m_window;
179  mutable Ogre::Timer m_timer;
180  Ogre::SharedPtr<Ogre::DataStream> m_config_file_data;
181 };
182 
183 } // namespace GG
184 
185 #endif