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
68namespace CEGUI {
69
76class OPENGL_GUIRENDERER_API OpenGLInfo
77{
78
79public:
84 enum Type
85 {
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
162 { return d_isReadBufferSupported; }
163
169 { return d_isPolygonModeSupported; }
170
175 bool isVaoSupported() const { return d_isVaoSupported; }
176
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
197private:
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_
Provides information about the type of OpenGL used by an OpenGL context (desktop OpenGL or OpenGL ES)...
Definition: GL.h:77
bool isNpotTextureSupported() const
Returns true if NPOT (non-power-of-two) textures are supported.
Definition: GL.h:155
Type type() const
Type of the OpenGL (desktop or ES) context.
Definition: GL.h:106
bool isUsingDesktopOpengl() const
Returns true if using Desktop OpenGL.
Definition: GL.h:112
bool verAtLeast(GLint major, GLint minor)
Returns true if the OpenGL (desktop or ES) version is at least "major.minor". Only supports Epoxy!...
Definition: GL.h:139
GLint verMajor() const
Returns OpenGL (desktop or ES) major version. Only supports Epoxy! Otherwise returns -1;.
Definition: GL.h:125
Type
Type of the OpenGL (desktop or ES) context.
Definition: GL.h:85
@ TYPE_DESKTOP
Definition: GL.h:87
@ TYPE_NONE
Definition: GL.h:86
bool isSeperateReadAndDrawFramebufferSupported() const
Returns true if working with the read/draw framebuffers seperately is supported.
Definition: GL.h:182
bool isS3tcSupported() const
Returns true if "S3TC" texture compression is supported.
Definition: GL.h:149
bool isVaoSupported() const
Returns true if VAO-s (Vertex Array Objects) are supported.
Definition: GL.h:175
bool isUsingOpenglEs() const
Returns true if using OpenGL ES.
Definition: GL.h:118
void init()
Must be called before any other method.
GLint verMinor() const
Returns OpenGL (desktop or ES) minor version. Only supports Epoxy! Otherwise returns -1;.
Definition: GL.h:132
bool isReadBufferSupported() const
Returns true if "glReadBuffer" is supported.
Definition: GL.h:161
bool isPolygonModeSupported() const
Returns true if "glPolygonMode" is supported.
Definition: GL.h:168
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1