1 | /* |
---|
2 | ----------------------------------------------------------------------------- |
---|
3 | This source file is part of OGRE |
---|
4 | (Object-oriented Graphics Rendering Engine) |
---|
5 | For the latest info, see http://www.ogre3d.org |
---|
6 | |
---|
7 | Copyright (c) 2000-2006 Torus Knot Software Ltd |
---|
8 | Also see acknowledgements in Readme.html |
---|
9 | |
---|
10 | This program is free software; you can redistribute it and/or modify it under |
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software |
---|
12 | Foundation; either version 2 of the License, or (at your option) any later |
---|
13 | version. |
---|
14 | |
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT |
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU Lesser General Public License along with |
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
---|
22 | http://www.gnu.org/copyleft/lesser.txt. |
---|
23 | |
---|
24 | You may alternatively use this source under the terms of a specific version of |
---|
25 | the OGRE Unrestricted License provided you have obtained such a license from |
---|
26 | Torus Knot Software Ltd. |
---|
27 | ----------------------------------------------------------------------------- |
---|
28 | */ |
---|
29 | |
---|
30 | #ifndef INCL_OGRE_GTKGLSUPPORT_H |
---|
31 | #define INCL_OGRE_GTKGLSUPPORT_H |
---|
32 | |
---|
33 | #include "OgreGLSupport.h" |
---|
34 | |
---|
35 | #include <gtkmm/main.h> |
---|
36 | #include <gtkglmm.h> |
---|
37 | |
---|
38 | namespace Ogre { |
---|
39 | |
---|
40 | class OGREWidget; |
---|
41 | |
---|
42 | /** |
---|
43 | * GL support in a GTK window. |
---|
44 | * |
---|
45 | * I made this a Singleton, so that the main context can be queried by |
---|
46 | * GTKWindows. |
---|
47 | */ |
---|
48 | class GTKGLSupport : public GLSupport, public Singleton<GTKGLSupport> |
---|
49 | { |
---|
50 | public: |
---|
51 | GTKGLSupport(); |
---|
52 | void addConfig(); |
---|
53 | void setConfigOptions(const String& name, const String& value); |
---|
54 | String validateConfig(); |
---|
55 | RenderWindow* createWindow(bool autoCreateWindow, |
---|
56 | GLRenderSystem* renderSystem, const String& windowTitle); |
---|
57 | RenderWindow* newWindow(const String& name, unsigned int width, unsigned int height, |
---|
58 | unsigned int colourDepth, bool fullScreen, int left, int top, |
---|
59 | bool depthBuffer, RenderWindow* parentWindowHandle, |
---|
60 | bool vsync); |
---|
61 | void start(); |
---|
62 | void stop(); |
---|
63 | void begin_context(RenderTarget *_target = 0); |
---|
64 | void end_context(); |
---|
65 | void initialiseExtensions(void); |
---|
66 | bool checkMinGLVersion(const String& v) const; |
---|
67 | bool checkExtension(const String& ext) const; |
---|
68 | void* getProcAddress(const String& procname); |
---|
69 | |
---|
70 | Glib::RefPtr<const Gdk::GL::Context> getMainContext() const; |
---|
71 | |
---|
72 | /** Override standard Singleton retrieval. |
---|
73 | @remarks |
---|
74 | Why do we do this? Well, it's because the Singleton |
---|
75 | implementation is in a .h file, which means it gets compiled |
---|
76 | into anybody who includes it. This is needed for the |
---|
77 | Singleton template to work, but we actually only want it |
---|
78 | compiled into the implementation of the class based on the |
---|
79 | Singleton, not all of them. If we don't change this, we get |
---|
80 | link errors when trying to use the Singleton-based class from |
---|
81 | an outside dll. |
---|
82 | @par |
---|
83 | This method just delegates to the template version anyway, |
---|
84 | but the implementation stays in this single compilation unit, |
---|
85 | preventing link errors. |
---|
86 | */ |
---|
87 | static GTKGLSupport& getSingleton(void); |
---|
88 | /** Override standard Singleton retrieval. |
---|
89 | @remarks |
---|
90 | Why do we do this? Well, it's because the Singleton |
---|
91 | implementation is in a .h file, which means it gets compiled |
---|
92 | into anybody who includes it. This is needed for the |
---|
93 | Singleton template to work, but we actually only want it |
---|
94 | compiled into the implementation of the class based on the |
---|
95 | Singleton, not all of them. If we don't change this, we get |
---|
96 | link errors when trying to use the Singleton-based class from |
---|
97 | an outside dll. |
---|
98 | @par |
---|
99 | This method just delegates to the template version anyway, |
---|
100 | but the implementation stays in this single compilation unit, |
---|
101 | preventing link errors. |
---|
102 | */ |
---|
103 | static GTKGLSupport* getSingletonPtr(void); |
---|
104 | private: |
---|
105 | int _context_ref; |
---|
106 | Gtk::Main _kit; |
---|
107 | //OGREWidget* _ogre_widget; |
---|
108 | |
---|
109 | Glib::RefPtr<Gdk::GL::Context> _main_context; |
---|
110 | Glib::RefPtr<Gdk::GL::Window> _main_window; |
---|
111 | }; // class GTKGLSupport |
---|
112 | |
---|
113 | }; // namespace Ogre |
---|
114 | |
---|
115 | #endif // INCL_OGRE_GTKGLSUPPORT_H |
---|