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-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef OGRE_GLSUPPORT_H
29 #define OGRE_GLSUPPORT_H
30 
31 #include "OgreGLPrerequisites.h"
32 #include "OgreGLRenderSystem.h"
33 
34 #include "OgreRenderWindow.h"
35 #include "OgreConfigOptionMap.h"
36 #include "OgreGLPBuffer.h"
37 
38 namespace Ogre
39 {
40 
41 class GLStateCacheManager;
42 
43 class _OgreGLExport GLSupport
44 {
45 public:
GLSupport()46     GLSupport() { }
~GLSupport()47     virtual ~GLSupport() { }
48 
49     /**
50     * Add any special config values to the system.
51     * Must have a "Full Screen" value that is a bool and a "Video Mode" value
52     * that is a string in the form of wxh
53     */
54     virtual void addConfig() = 0;
55 
56 	virtual void setConfigOption(const String &name, const String &value);
57 
58     /**
59     * Make sure all the extra options are valid
60     * @return string with error message
61     */
62     virtual String validateConfig() = 0;
63 
64 	virtual ConfigOptionMap& getConfigOptions(void);
65 
66 	virtual RenderWindow* createWindow(bool autoCreateWindow, GLRenderSystem* renderSystem, const String& windowTitle) = 0;
67 
68 	/// @copydoc RenderSystem::_createRenderWindow
69 	virtual RenderWindow* newWindow(const String &name, unsigned int width, unsigned int height,
70 		bool fullScreen, const NameValuePairList *miscParams = 0) = 0;
71 
72     virtual bool supportsPBuffers();
73     virtual GLPBuffer *createPBuffer(PixelComponentType format, size_t width, size_t height);
74 
getStateCacheManager()75     GLStateCacheManager* getStateCacheManager() const
76     {
77         return mStateCacheManager;
78     }
79 
setStateCacheManager(GLStateCacheManager * stateCacheMgr)80     void setStateCacheManager(GLStateCacheManager* stateCacheMgr)
81     {
82         mStateCacheManager = stateCacheMgr;
83     }
84 
85     /**
86     * Start anything special
87     */
88     virtual void start() = 0;
89     /**
90     * Stop anything special
91     */
92     virtual void stop() = 0;
93 
94     /**
95     * Get vendor information
96     */
getGLVendor(void)97     const String& getGLVendor(void) const
98     {
99         return mVendor;
100     }
101 
102     /**
103     * Get version information
104     */
getGLVersion(void)105     const String& getGLVersion(void) const
106     {
107         return mVersion;
108     }
109 
110     /**
111     * Compare GL version numbers
112     */
113     bool checkMinGLVersion(const String& v) const;
114 
115     /**
116     * Check if an extension is available
117     */
118     virtual bool checkExtension(const String& ext) const;
119     /**
120     * Get the address of a function
121     */
122     virtual void* getProcAddress(const String& procname) = 0;
123 
124     /** Initialises GL extensions, must be done AFTER the GL context has been
125         established.
126     */
127     virtual void initialiseExtensions();
128 
129 	/// @copydoc RenderSystem::getDisplayMonitorCount
getDisplayMonitorCount()130 	virtual unsigned int getDisplayMonitorCount() const
131 	{
132 		return 1;
133 	}
134 
135 protected:
136 	// Stored options
137     ConfigOptionMap mOptions;
138 
139 	// This contains the complete list of supported extensions
140     set<String>::type extensionList;
141 private:
142     String mVersion;
143     String mVendor;
144 
145     GLStateCacheManager* mStateCacheManager;
146 
147 }; // class GLSupport
148 
149 } // namespace Ogre
150 
151 #endif // OGRE_GLSUPPORT_H
152