Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
OpenGL.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef OpenGL_INCLUDE_ONCE
33 #define OpenGL_INCLUDE_ONCE
34 
36 #include <vlCore/OpenGLDefs.hpp>
37 #include <vlCore/Log.hpp>
38 
39 namespace vl
40 {
43 
49 
55 
60 
61  VLGRAPHICS_EXPORT extern const GLenum Translate_Enable[];
63  VLGRAPHICS_EXPORT extern const char* Translate_Enable_String[];
64 
67  VLGRAPHICS_EXPORT extern bool Has_GLES;
68 
82 
83  // Helper variables
84 
85  VLGRAPHICS_EXPORT extern bool Has_GLSL;
95  VLGRAPHICS_EXPORT extern bool Has_FBO;
96  VLGRAPHICS_EXPORT extern bool Has_PBO;
103  VLGRAPHICS_EXPORT extern bool Has_Texture_3D;
113 
114  #define VL_EXTENSION(extension) VLGRAPHICS_EXPORT extern bool Has_##extension;
115  #include <vlGraphics/GL/GLExtensionList.hpp>
116  #undef VL_EXTENSION
117 
118  #define VL_GLES_EXTENSION(extension) VLGRAPHICS_EXPORT extern bool Has_##extension;
119  #include <vlGraphics/GL/GLESExtensionList.hpp>
120  #undef VL_GLES_EXTENSION
121 
122  #if defined(VL_OPENGL)
123  #define VL_GL_FUNCTION(TYPE, NAME) VLGRAPHICS_EXPORT extern TYPE NAME;
124  #include <vlGraphics/GL/GLFunctionList.hpp>
125  #undef VL_GL_FUNCTION
126  #endif
127 
128  #if defined(VL_OPENGL_ES1)
129  #define VL_GL_FUNCTION(TYPE, NAME) VLGRAPHICS_EXPORT extern TYPE NAME;
130  #include <vlGraphics/GL/GLES1FunctionList.hpp>
131  #undef VL_GL_FUNCTION
132  #endif
133 
134  #if defined(VL_OPENGL_ES2)
135  #define VL_GL_FUNCTION(TYPE, NAME) VLGRAPHICS_EXPORT extern TYPE NAME;
136  #include <vlGraphics/GL/GLES2FunctionList.hpp>
137  #undef VL_GL_FUNCTION
138  #endif
139 
142 
144  VLGRAPHICS_EXPORT void* getGLProcAddress(const char* name);
145 
147  VLGRAPHICS_EXPORT const char* getGLErrorString(int err);
148 
149  //-----------------------------------------------------------------------------
150  // VL_CHECK_OGL
151  //-----------------------------------------------------------------------------
152 
153  VLGRAPHICS_EXPORT int glcheck( const char* file, int line );
154 
155  #if defined( _DEBUG ) || !defined( NDEBUG ) || VL_FORCE_CHECKS == 1
156  #define VL_CHECK_OGL( ) { if ( ::vl::glcheck( __FILE__, __LINE__ ) ) { VL_TRAP( ) } }
157  #else
158  #define VL_CHECK_OGL( );
159  #endif
160 
161  //------------------------------------------------------------------------------
162 
163 }
164 
165 //-----------------------------------------------------------------------------
166 // OpenGL functions wrappers
167 //-----------------------------------------------------------------------------
168 
169 #if defined(VL_OPENGL)
170  #include <vlGraphics/GL/VL_Functions_GL.hpp>
171 #endif
172 
173 #if defined(VL_OPENGL_ES1)
174  #include <vlGraphics/GL/VL_Functions_GLES1.hpp>
175 #endif
176 
177 #if defined(VL_OPENGL_ES2)
178  #include <vlGraphics/GL/VL_Functions_GLES2.hpp>
179 #endif
180 //-----------------------------------------------------------------------------
181 #endif
bool Has_GLES_Version_1_1
Definition: OpenGL.cpp:67
bool Has_GL_Version_1_4
Definition: OpenGL.cpp:52
bool Has_Cubemap_Textures
Definition: OpenGL.cpp:86
const GLenum Translate_Enable[]
Definition: OpenGL.cpp:128
bool Has_Texture_Multisample
Definition: OpenGL.cpp:90
bool Has_GL_Version_4_1
Definition: OpenGL.cpp:61
bool Has_GLSL_140_Or_More
Definition: OpenGL.cpp:76
bool Has_glGenerateMipmaps
Definition: OpenGL.cpp:96
bool Has_GL_Version_1_1
Definition: OpenGL.cpp:49
bool Has_Multitexture
Definition: OpenGL.cpp:92
const char * Translate_Enable_String[]
Definition: OpenGL.cpp:185
bool Has_GLSL_410_Or_More
Definition: OpenGL.cpp:80
bool Has_GLSL_150_Or_More
Definition: OpenGL.cpp:77
bool Has_GLSL_400_Or_More
Definition: OpenGL.cpp:79
bool Has_GL_Version_2_1
Definition: OpenGL.cpp:55
VLGRAPHICS_EXPORT void * getGLProcAddress(const char *name)
Returns the address of the specified OpenGL function if supported by the active OpenGL driver and pro...
Definition: OpenGL.cpp:719
bool Is_OpenGL_Forward_Compatible
OpenGL: true if the current context has been created with the WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB ...
Definition: OpenGL.cpp:47
VLGRAPHICS_EXPORT int glcheck(const char *file, int line)
Definition: OpenGL.cpp:606
bool Has_Point_Sprite
Definition: OpenGL.cpp:98
bool Has_Texture_Rectangle
Definition: OpenGL.cpp:87
bool Has_GL_Version_3_3
Definition: OpenGL.cpp:59
bool Has_Primitive_Instancing
Definition: OpenGL.cpp:100
bool Has_GL_Version_4_0
Definition: OpenGL.cpp:60
bool Is_OpenGL_Core_Profile
OpenGL: true if the current context has been created with the WGL_CONTEXT_CORE_PROFILE_BIT_ARB or equ...
Definition: OpenGL.cpp:46
bool Is_OpenGL_Initialized
Set to true if the last call to vl::initializeOpenGL() was succesful.
Definition: OpenGL.cpp:45
bool Has_GL_Version_3_0
Definition: OpenGL.cpp:56
Visualization Library main namespace.
bool Has_GLSL
Definition: OpenGL.cpp:73
bool Has_BufferObject
Definition: OpenGL.cpp:82
bool Has_GLES_Version_2_0
Definition: OpenGL.cpp:68
bool Has_Texture_Array
Definition: OpenGL.cpp:88
bool Has_Transform_Feedback
Definition: OpenGL.cpp:95
bool Has_GL_Version_1_3
Definition: OpenGL.cpp:51
bool Has_GLSL_120_Or_More
Definition: OpenGL.cpp:74
VLGRAPHICS_EXPORT bool initializeOpenGL()
To test whether OpenGL has been initialized at least once check vl::Is_OpenGL_Initialized.
Definition: OpenGL.cpp:304
bool Has_GL_Version_1_5
Definition: OpenGL.cpp:53
bool Has_GL_Version_3_2
Definition: OpenGL.cpp:58
bool Has_GL_GENERATE_MIPMAP
Definition: OpenGL.cpp:97
bool Has_Occlusion_Query
Definition: OpenGL.cpp:94
bool Has_GLES
Definition: OpenGL.cpp:69
bool Has_Geometry_Shader
Definition: OpenGL.cpp:81
bool Has_Texture_Buffer
Definition: OpenGL.cpp:89
bool Has_GL_Version_3_1
Definition: OpenGL.cpp:57
VLGRAPHICS_EXPORT const char * getGLErrorString(int err)
Returns a readable string corresponding to the given OpenGL error code as returned by glGetError() ...
Definition: OpenGL.cpp:591
bool Has_GLSL_330_Or_More
Definition: OpenGL.cpp:78
bool Has_GL_Version_2_0
Definition: OpenGL.cpp:54
bool Has_GLSL_130_Or_More
Definition: OpenGL.cpp:75
bool Has_Fixed_Function_Pipeline
OpenGL: true if !Is_OpenGL_Forward_Compatible && !Is_OpenGL_Core_Profile OpenGL ES 1: always true Ope...
Definition: OpenGL.cpp:63
bool Has_Base_Vertex
Definition: OpenGL.cpp:99
bool Has_Primitive_Restart
Definition: OpenGL.cpp:93
bool Is_Enable_Supported[EN_EnableCount]
Definition: OpenGL.cpp:242
bool Has_PBO
Definition: OpenGL.cpp:84
bool Has_GL_Version_1_2
Definition: OpenGL.cpp:50
bool Has_FBO
Definition: OpenGL.cpp:83
bool Has_Texture_3D
Definition: OpenGL.cpp:91
bool Has_FBO_Multisample
Definition: OpenGL.cpp:85