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-2014 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 
29 #ifndef __GLNativeSupport_H__
30 #define __GLNativeSupport_H__
31 
32 #include "OgreGLSupportPrerequisites.h"
33 #include "OgreConfigOptionMap.h"
34 #include "OgrePixelFormat.h"
35 #include "OgreException.h"
36 #include "OgreGLRenderSystemCommon.h"
37 
38 namespace Ogre
39 {
40     class GLPBuffer;
41 
42     /** \addtogroup RenderSystems RenderSystems
43     *  @{
44     */
45     /** \defgroup GLSupport GLSupport
46     * provides OpenGL Context creation using GLX, WGL, EGL, Cocoa
47     *  @{
48     */
49     class _OgreGLExport GLNativeSupport
50     {
51         public:
52             typedef GLRenderSystemCommon::VideoModes VideoModes;
53             typedef std::set<String> ExtensionList;
54 
55             enum ContextProfile {
56                 CONTEXT_CORE = 1,
57                 CONTEXT_COMPATIBILITY = 2,
58                 CONTEXT_ES = 4
59             };
60 
GLNativeSupport(int profile)61             GLNativeSupport(int profile) : mContextProfile(ContextProfile(profile)) {}
~GLNativeSupport()62             virtual ~GLNativeSupport() {}
63 
64             /// @copydoc RenderSystem::_createRenderWindow
65             virtual RenderWindow* newWindow(const String &name,
66                                             unsigned int width, unsigned int height,
67                                             bool fullScreen,
68                                             const NameValuePairList *miscParams = 0) = 0;
69 
createPBuffer(PixelComponentType format,size_t width,size_t height)70             virtual GLPBuffer* createPBuffer(PixelComponentType format, size_t width, size_t height) {
71                 return NULL;
72             }
73 
74             /**
75             * Get the address of a function
76             */
77             virtual void *getProcAddress(const char* procname) const = 0;
78 
checkExtension(const String & ext)79             bool checkExtension(const String& ext) const {
80                 return extensionList.find(ext) != extensionList.end();
81             }
82 
83             /// @copydoc RenderSystem::getDisplayMonitorCount
getDisplayMonitorCount()84             virtual unsigned int getDisplayMonitorCount() const
85             {
86                 return 1;
87             }
88 
89             /**
90             * Start anything special
91             */
92             virtual void start() = 0;
93             /**
94             * Stop anything special
95             */
96             virtual void stop() = 0;
97 
98             /**
99             * Add any special config values to the system.
100             */
getConfigOptions()101             virtual ConfigOptionMap getConfigOptions() { return ConfigOptionMap(); }
102 
getFSAALevels()103             const std::vector<int>& getFSAALevels() const { return mFSAALevels; }
getVideoModes()104             const VideoModes& getVideoModes() const { return mVideoModes; }
105 
getContextProfile()106             ContextProfile getContextProfile() const { return mContextProfile; }
107         protected:
108             typedef GLRenderSystemCommon::VideoMode VideoMode;
109 
110             // Allowed video modes
111             VideoModes mVideoModes;
112             std::vector<int> mFSAALevels;
113 
114             // Supported platform extensions (e.g EGL_*, GLX_*)
115             ExtensionList extensionList;
116 
117             ContextProfile mContextProfile;
118     };
119     /** @} */
120     /** @} */
121 
122 }
123 
124 #endif
125