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# if !defined(CEGUI_DONT_USE_GLEW_LOCALLY)
39#include <GL/glew.h>
40# endif
41
42// When using GLEW, there's no need to "#include" the OpenGL headers.
43#ifndef __APPLE__
44# if (defined( __WIN32__ ) || defined( _WIN32 ))
45# include <windows.h>
46# endif
47# include <GL/glu.h>
48#else
49# include <OpenGL/glu.h>
50#endif
51
52#else
53#error Either "CEGUI_USE_EPOXY" or "CEGUI_USE_GLEW" must be defined. Defining both or none is invalid.
54#endif
55
56#ifndef GL_RGB565
57#define GL_RGB565 0x8D62
58#endif
59
60#if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
61# if defined(CEGUIOPENGLRENDERER_EXPORTS) || defined(CEGUIOPENGLES2RENDERER_EXPORTS)
62# define OPENGL_GUIRENDERER_API __declspec(dllexport)
63# else
64# define OPENGL_GUIRENDERER_API __declspec(dllimport)
65# endif
66#else
67# define OPENGL_GUIRENDERER_API
68#endif
69
70namespace CEGUI {
71
78class OPENGL_GUIRENDERER_API OpenGLInfo
79{
80
81public:
86 enum Type
87 {
90 TYPE_ES
91 };
92
93 static OpenGLInfo& getSingleton() { return s_instance; }
94
102 void init();
103
108 Type type() const { return d_type; }
109
114 bool isUsingDesktopOpengl() const { return type() == TYPE_DESKTOP; }
115
120 bool isUsingOpenglEs() const { return type() == TYPE_ES; }
121
127 GLint verMajor() const { return d_verMajor; }
128
134 GLint verMinor() const { return d_verMinor; }
135
141 bool verAtLeast(GLint major, GLint minor) {
142 return verMajor() > major || (verMajor() == major && verMinor() >= minor); }
143
151 bool isS3tcSupported() const { return d_isS3tcSupported; }
152
157 bool isNpotTextureSupported() const { return d_isNpotTextureSupported; }
158
164 { return d_isReadBufferSupported; }
165
171 { return d_isPolygonModeSupported; }
172
177 bool isVaoSupported() const { return d_isVaoSupported; }
178
185 { return d_isSeperateReadAndDrawFramebufferSupported; }
186
187 bool isSizedInternalFormatSupported() const
188 { return d_isSizedInternalFormatSupported; }
189
190 /* For internal use. Used to force the object to act is if we're using a
191 context of the specificed "verMajor_.verMinor_". This is useful to
192 check that an OpenGL (desktop/ES) version lower than the actual one
193 works correctly. Of course, this should work only if the actual
194 version is compatible with the forced version. For example this can be
195 used to check OpenGL ES 2.0 when the context is actually OpenGL ES 3.0
196 (which is compatible with OpenGL ES 2.0). */
197 void verForce(GLint verMajor_, GLint verMinor_);
198
199private:
200
201 static OpenGLInfo s_instance;
202 OpenGLInfo();
203 void initTypeAndVer();
204 void initSupportedFeatures();
205
206 Type d_type;
207 GLint d_verMajor;
208 GLint d_verMinor;
209 GLint d_verMajorForce;
210 GLint d_verMinorForce;
211 bool d_isS3tcSupported;
212 bool d_isNpotTextureSupported;
213 bool d_isReadBufferSupported;
214 bool d_isPolygonModeSupported;
215 bool d_isSeperateReadAndDrawFramebufferSupported;
216 bool d_isVaoSupported;
217 bool d_isSizedInternalFormatSupported;
218};
219
220} // namespace CEGUI
221
222#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:79
bool isNpotTextureSupported() const
Returns true if NPOT (non-power-of-two) textures are supported.
Definition: GL.h:157
Type type() const
Type of the OpenGL (desktop or ES) context.
Definition: GL.h:108
bool isUsingDesktopOpengl() const
Returns true if using Desktop OpenGL.
Definition: GL.h:114
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:141
GLint verMajor() const
Returns OpenGL (desktop or ES) major version. Only supports Epoxy! Otherwise returns -1;.
Definition: GL.h:127
Type
Type of the OpenGL (desktop or ES) context.
Definition: GL.h:87
@ TYPE_DESKTOP
Definition: GL.h:89
@ TYPE_NONE
Definition: GL.h:88
bool isSeperateReadAndDrawFramebufferSupported() const
Returns true if working with the read/draw framebuffers seperately is supported.
Definition: GL.h:184
bool isS3tcSupported() const
Returns true if "S3TC" texture compression is supported.
Definition: GL.h:151
bool isVaoSupported() const
Returns true if VAO-s (Vertex Array Objects) are supported.
Definition: GL.h:177
bool isUsingOpenglEs() const
Returns true if using OpenGL ES.
Definition: GL.h:120
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:134
bool isReadBufferSupported() const
Returns true if "glReadBuffer" is supported.
Definition: GL.h:163
bool isPolygonModeSupported() const
Returns true if "glPolygonMode" is supported.
Definition: GL.h:170
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1