Crazy Eddie's GUI System  0.8.7
GL.h
1 /***********************************************************************
2  created: Fri Jan 23 2009
3  author: Paul D Turner
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _CEGUIOpenGL_h_
28 #define _CEGUIOpenGL_h_
29 
30 #include "CEGUI/Config.h"
31 
32 #if defined CEGUI_USE_EPOXY
33 
34 #include <epoxy/gl.h>
35 
36 #elif defined CEGUI_USE_GLEW
37 
38 #include <GL/glew.h>
39 
40 // When using GLEW, there's no need to "#include" the OpenGL headers.
41 #ifndef __APPLE__
42 # if (defined( __WIN32__ ) || defined( _WIN32 ))
43 # include <windows.h>
44 # endif
45 # include <GL/glu.h>
46 #else
47 # include <OpenGL/glu.h>
48 #endif
49 
50 #else
51 #error Either "CEGUI_USE_EPOXY" or "CEGUI_USE_GLEW" must be defined. Defining both or none is invalid.
52 #endif
53 
54 #ifndef GL_RGB565
55 #define GL_RGB565 0x8D62
56 #endif
57 
58 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
59 # if defined(CEGUIOPENGLRENDERER_EXPORTS) || defined(CEGUIOPENGLES2RENDERER_EXPORTS)
60 # define OPENGL_GUIRENDERER_API __declspec(dllexport)
61 # else
62 # define OPENGL_GUIRENDERER_API __declspec(dllimport)
63 # endif
64 #else
65 # define OPENGL_GUIRENDERER_API
66 #endif
67 
68 namespace CEGUI {
69 
76 class OPENGL_GUIRENDERER_API OpenGLInfo
77 {
78 
79 public:
84  enum Type
85  {
86  TYPE_NONE,
87  TYPE_DESKTOP,
88  TYPE_ES
89  };
90 
91  static OpenGLInfo& getSingleton() { return s_instance; }
92 
100  void init();
101 
106  Type type() const { return d_type; }
107 
112  bool isUsingDesktopOpengl() const { return type() == TYPE_DESKTOP; }
113 
118  bool isUsingOpenglEs() const { return type() == TYPE_ES; }
119 
125  GLint verMajor() const { return d_verMajor; }
126 
132  GLint verMinor() const { return d_verMinor; }
133 
139  bool verAtLeast(GLint major, GLint minor) {
140  return verMajor() > major || (verMajor() == major && verMinor() >= minor); }
141 
149  bool isS3tcSupported() const { return d_isS3tcSupported; }
150 
155  bool isNpotTextureSupported() const { return d_isNpotTextureSupported; }
156 
161  bool isReadBufferSupported() const
162  { return d_isReadBufferSupported; }
163 
168  bool isPolygonModeSupported() const
169  { return d_isPolygonModeSupported; }
170 
175  bool isVaoSupported() const { return d_isVaoSupported; }
176 
182  bool isSeperateReadAndDrawFramebufferSupported() const
183  { return d_isSeperateReadAndDrawFramebufferSupported; }
184 
185  bool isSizedInternalFormatSupported() const
186  { return d_isSizedInternalFormatSupported; }
187 
188  /* For internal use. Used to force the object to act is if we're using a
189  context of the specificed "verMajor_.verMinor_". This is useful to
190  check that an OpenGL (desktop/ES) version lower than the actual one
191  works correctly. Of course, this should work only if the actual
192  version is compatible with the forced version. For example this can be
193  used to check OpenGL ES 2.0 when the context is actually OpenGL ES 3.0
194  (which is compatible with OpenGL ES 2.0). */
195  void verForce(GLint verMajor_, GLint verMinor_);
196 
197 private:
198 
199  static OpenGLInfo s_instance;
200  OpenGLInfo();
201  void initTypeAndVer();
202  void initSupportedFeatures();
203 
204  Type d_type;
205  GLint d_verMajor;
206  GLint d_verMinor;
207  GLint d_verMajorForce;
208  GLint d_verMinorForce;
209  bool d_isS3tcSupported;
210  bool d_isNpotTextureSupported;
211  bool d_isReadBufferSupported;
212  bool d_isPolygonModeSupported;
213  bool d_isSeperateReadAndDrawFramebufferSupported;
214  bool d_isVaoSupported;
215  bool d_isSizedInternalFormatSupported;
216 };
217 
218 } // namespace CEGUI
219 
220 #endif // end of guard _CEGUIOpenGL_h_
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::OpenGLInfo::Type
Type
Type of the OpenGL (desktop or ES) context.
Definition: GL.h:82
CEGUI::OpenGLInfo
Provides information about the type of OpenGL used by an OpenGL context (desktop OpenGL or OpenGL ES)...
Definition: GL.h:74