GG
|
00001 // -*- C++ -*- 00002 /* GG is a GUI for SDL and OpenGL. 00003 Copyright (C) 2007 T. Zachary Laine 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public License 00007 as published by the Free Software Foundation; either version 2.1 00008 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 00018 02111-1307 USA 00019 00020 If you do not wish to comply with the terms of the LGPL please 00021 contact the author as other terms are available for a fee. 00022 00023 Zach Laine 00024 whatwasthataddress@gmail.com */ 00025 00029 #ifndef _GG_OgreGUI_h_ 00030 #define _GG_OgreGUI_h_ 00031 00032 #ifdef __APPLE__ 00033 /* prevents OpenTransportProviders.h (a system header in Mac SDKs) 00034 from trying to enum what's already defined by related headers */ 00035 #undef TCP_NODELAY 00036 #undef TCP_MAXSEG 00037 #undef TCP_NOTIFY_THRESHOLD 00038 #undef TCP_ABORT_THRESHOLD 00039 #undef TCP_CONN_NOTIFY_THRESHOLD 00040 #undef TCP_CONN_ABORT_THRESHOLD 00041 #undef TCP_OOBINLINE 00042 #undef TCP_URGENT_PTR_TYPE 00043 #undef TCP_KEEPALIVE 00044 #include <Carbon/Carbon.h> 00045 #endif 00046 00047 #include <OgreDataStream.h> 00048 #include <OgreRenderTargetListener.h> 00049 #include <OgreSharedPtr.h> 00050 #include <OgreTimer.h> 00051 #include <OgreWindowEventUtilities.h> 00052 00053 #include <GG/GUI.h> 00054 00055 00056 #ifdef _MSC_VER 00057 # ifdef GiGiOgre_EXPORTS 00058 # define GG_OGRE_API __declspec(dllexport) 00059 # else 00060 # define GG_OGRE_API __declspec(dllimport) 00061 # endif 00062 #else 00063 # define GG_OGRE_API 00064 #endif 00065 00066 namespace Ogre { 00067 class RenderWindow; 00068 } 00069 00070 namespace GG { 00071 00123 class GG_OGRE_API OgreGUI : 00124 public GUI, 00125 public Ogre::RenderTargetListener, 00126 public Ogre::WindowEventListener 00127 { 00128 public: 00132 explicit OgreGUI(Ogre::RenderWindow* window, const std::string& config_filename = ""); 00133 00135 virtual ~OgreGUI(); 00136 00138 virtual boost::shared_ptr<ModalEventPump> CreateModalEventPump(bool& done); 00139 00140 virtual unsigned int Ticks() const; 00141 virtual X AppWidth() const; 00142 virtual Y AppHeight() const; 00143 00147 const Ogre::SharedPtr<Ogre::DataStream>& ConfigFileStream() const; 00148 00149 virtual void Exit(int code); 00150 00153 boost::signal<void ()> HandleSystemEventsSignal; 00154 00156 boost::signal<void (X, Y)> WindowResizedSignal; 00157 00160 boost::signal<void ()> WindowClosedSignal; 00161 00163 static OgreGUI* GetGUI(); 00164 00165 protected: 00166 virtual void RenderBegin(); 00167 virtual void RenderEnd(); 00168 virtual void Run(); 00169 virtual void HandleSystemEvents(); 00170 virtual void Enter2DMode(); 00171 virtual void Exit2DMode(); 00172 00173 private: 00174 virtual void postRenderTargetUpdate(const Ogre::RenderTargetEvent& event); 00175 virtual void windowResized(Ogre::RenderWindow* window); 00176 virtual void windowClosed(Ogre::RenderWindow* window); 00177 00178 Ogre::RenderWindow* m_window; 00179 mutable Ogre::Timer m_timer; 00180 Ogre::SharedPtr<Ogre::DataStream> m_config_file_data; 00181 }; 00182 00183 } // namespace GG 00184 00185 #endif // _GG_OgreGUI_h_