38 #if defined(VL_OPENGL_ES1) || defined(VL_OPENGL_ES2) 102 #define VL_EXTENSION(extension) bool Has_##extension = false; 103 #include <vlGraphics/GL/GLExtensionList.hpp> 106 #define VL_GLES_EXTENSION(extension) bool Has_##extension = false; 107 #include <vlGraphics/GL/GLESExtensionList.hpp> 108 #undef VL_GLES_EXTENSION 110 #if defined(VL_OPENGL) 111 #define VL_GL_FUNCTION(TYPE, NAME) TYPE NAME = NULL; 112 #include <vlGraphics/GL/GLFunctionList.hpp> 113 #undef VL_GL_FUNCTION 116 #if defined(VL_OPENGL_ES1) 117 #define VL_GL_FUNCTION(TYPE, NAME) TYPE NAME = NULL; 118 #include <vlGraphics/GL/GLES1FunctionList.hpp> 119 #undef VL_GL_FUNCTION 122 #if defined(VL_OPENGL_ES2) 123 #define VL_GL_FUNCTION(TYPE, NAME) TYPE NAME = NULL; 124 #include <vlGraphics/GL/GLES2FunctionList.hpp> 125 #undef VL_GL_FUNCTION 136 GL_POLYGON_OFFSET_FILL,
137 GL_POLYGON_OFFSET_LINE,
138 GL_POLYGON_OFFSET_POINT,
153 GL_PROGRAM_POINT_SIZE,
164 GL_VERTEX_PROGRAM_TWO_SIDE,
167 GL_TEXTURE_CUBE_MAP_SEAMLESS,
180 GL_SAMPLE_ALPHA_TO_COVERAGE,
181 GL_SAMPLE_ALPHA_TO_ONE,
193 "GL_POLYGON_OFFSET_FILL",
194 "GL_POLYGON_OFFSET_LINE",
195 "GL_POLYGON_OFFSET_POINT",
206 "GL_POLYGON_STIPPLE",
210 "GL_PROGRAM_POINT_SIZE",
221 "GL_VERTEX_PROGRAM_TWO_SIDE",
224 "GL_TEXTURE_CUBE_MAP_SEAMLESS",
237 "GL_SAMPLE_ALPHA_TO_COVERAGE",
238 "GL_SAMPLE_ALPHA_TO_ONE",
312 if (glGetError() != GL_NO_ERROR)
318 #if defined(VL_OPENGL) 319 #define VL_GL_FUNCTION(TYPE, NAME) NAME = (TYPE)getGLProcAddress(#NAME); 320 #include <vlGraphics/GL/GLFunctionList.hpp> 324 #if defined(VL_OPENGL_ES1) 325 #define VL_GL_FUNCTION(TYPE, NAME) NAME = (TYPE)getGLProcAddress(#NAME); 326 #include <vlGraphics/GL/GLES1FunctionList.hpp> 330 #if defined(VL_OPENGL_ES2) 331 #define VL_GL_FUNCTION(TYPE, NAME) NAME = (TYPE)getGLProcAddress(#NAME); 332 #include <vlGraphics/GL/GLES2FunctionList.hpp> 338 #if defined(VL_OPENGL_ES1) 342 #if defined(VL_OPENGL_ES2) 348 const char* version_string = (
const char*)glGetString(GL_VERSION);
351 const int vmaj =
Has_GLES ? 0 : version_string[0] -
'0';
352 const int vmin =
Has_GLES ? 0 : version_string[2] -
'0';
355 #if defined(VL_OPENGL_ES2) 359 #elif defined(VL_OPENGL_ES1) 367 int forward_compatible = 0;
368 glGetIntegerv( GL_CONTEXT_FLAGS, &forward_compatible );
VL_CHECK_OGL();
373 const int version = vmaj*10 + vmin;
377 #define CONTEXT_CORE_PROFILE_BIT 0x00000001 378 #define CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 379 #define CONTEXT_PROFILE_MASK 0x9126 385 int context_flags = 0;
409 std::string extensions = getOpenGLExtensions();
411 #define VL_EXTENSION(extension) Has_##extension = strstr(extensions.c_str(), #extension" ") != NULL; 412 #include <vlGraphics/GL/GLExtensionList.hpp> 415 #define VL_GLES_EXTENSION(extension) Has_##extension = strstr(extensions.c_str(), #extension" ") != NULL; 416 #include <vlGraphics/GL/GLESExtensionList.hpp> 417 #undef VL_GLES_EXTENSION 419 #if defined(VL_OPENGL_ES1) 422 if (Has_GL_OES_texture_cube_map && glTexGenfOES == 0)
424 Has_GL_OES_texture_cube_map =
false;
426 Log::error(
"GL_OES_texture_cube_map exposed but glTexGenfOES == NULL!\n");
428 if(Has_GL_OES_blend_func_separate && glBlendFuncSeparateOES == 0)
430 Has_GL_OES_blend_func_separate =
false;
431 Log::error(
"GL_OES_blend_func_separate exposed but glBlendFuncSeparateOES == NULL!\n");
433 if (Has_GL_OES_fixed_point && glAlphaFuncxOES ==
NULL)
435 Log::warning(
"GL_OES_fixed_point functions are not exposed with their OES suffix!\n");
437 if (Has_GL_OES_single_precision && glDepthRangefOES ==
NULL)
439 Log::warning(
"GL_OES_single_precision functions are not exposed with their OES suffix!\n");
523 int max_clip_planes = 0;
527 glGetIntegerv(GL_MAX_CLIP_DISTANCES, &max_clip_planes);
545 if ( strstr( version_string,
" Mesa " ) ) {
546 Has_GL_ARB_get_program_binary =
false;
547 Has_GL_ARB_separate_shader_objects =
false;
553 bool got_error =
false;
557 bool supported = glGetError() == GL_NO_ERROR;
560 Log::error(
Say(
"%s: capability %s supported! This is a harmless glitch either in your GL driver or in VL.\n") <<
Translate_Enable_String[i] << (supported?
"*IS*" :
"*IS NOT*") );
566 printf(
"OpenGL Version = %s\n", glGetString(GL_VERSION));
567 #define PRINT_INFO(STRING) printf(#STRING" = %d\n", STRING?1:0) 595 case GL_INVALID_ENUM:
return "Invalid enum";
596 case GL_INVALID_VALUE:
return "Invalid value";
597 case GL_INVALID_OPERATION:
return "Invalid operation";
598 case GL_STACK_OVERFLOW:
return "Stack overflow";
599 case GL_STACK_UNDERFLOW:
return "Stack underflow";
600 case GL_OUT_OF_MEMORY:
return "Out of memory";
608 unsigned int glerr = glGetError();
612 Log::bug(
Say(
"%s:%n: NO OPENGL CONTEXT ACTIVE!\n") << file << line );
615 if (glerr != GL_NO_ERROR)
618 Log::bug(
Say(
"glGetError() [%s:%n]: %s\n") << file << line << msg );
625 #if defined(VL_OPENGL_ES1) || defined(VL_OPENGL_ES2) 628 void* func = (
void*)eglGetProcAddress(name);
635 #elif defined(VL_PLATFORM_WINDOWS) 638 return (
void*)wglGetProcAddress((LPCSTR)name);
640 #elif defined(VL_PLATFORM_LINUX) 643 return (
void*)(*glXGetProcAddress)((
const GLubyte*)name);
645 #elif defined(__APPLE__) 648 #include <AvailabilityMacros.h> 650 #ifdef MAC_OS_X_VERSION_10_3 656 static void* image =
NULL;
659 image = dlopen(
"/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY);
661 return image ? dlsym(image, name) :
NULL;
666 #include <mach-o/dyld.h> 670 static const struct mach_header* image =
NULL;
675 image = NSAddImage(
"/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", NSADDIMAGE_OPTION_RETURN_ON_ERROR);
678 symbolName = malloc(strlen(name) + 2);
679 strcpy(symbolName+1, name);
684 symbol = image ? NSLookupSymbolInImage(image, symbolName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) :
NULL;
686 return symbol ? NSAddressOfSymbol(symbol) :
NULL;
693 #elif defined(__sgi) || defined (__sun) 701 static void* h =
NULL;
706 if ((h = dlopen(
NULL, RTLD_LAZY | RTLD_LOCAL)) ==
NULL)
return NULL;
707 gpa = dlsym(h,
"glXGetProcAddress");
711 return ((
void*(*)(
const GLubyte*))gpa)((
const GLubyte*)name);
713 return dlsym(h, name);
bool Has_GLES_Version_1_1
If enabled, clip geometry against user-defined half space #7.
If enabled, clip geometry against user-defined half space #1.
bool Has_Cubemap_Textures
const GLenum Translate_Enable[]
bool Has_Texture_Multisample
bool Has_GLSL_140_Or_More
bool Has_glGenerateMipmaps
If enabled, do depth comparisons and update the depth buffer; Note that even if the depth buffer exis...
#define PRINT_INFO(STRING)
A simple String formatting class.
const char * Translate_Enable_String[]
bool Has_GLSL_410_Or_More
bool Has_GLSL_150_Or_More
static void warning(const String &message)
Use this function to provide information about situations that might lead to errors or loss of data...
bool Has_GLSL_400_Or_More
VLGRAPHICS_EXPORT void * getGLProcAddress(const char *name)
Returns the address of the specified OpenGL function if supported by the active OpenGL driver and pro...
#define CONTEXT_CORE_PROFILE_BIT
bool Is_OpenGL_Forward_Compatible
OpenGL: true if the current context has been created with the WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB ...
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
VLGRAPHICS_EXPORT int glcheck(const char *file, int line)
If enabled, use the current polygon stipple pattern when rendering polygons, see also PolygonStipple...
If enabled, use the current lighting parameters to compute the vertex color; Otherwise, simply associate the current color with each vertex, see also Material, LightModel, and Light.
[GL_VERTEX_PROGRAM_POINT_SIZE/GL_PROGRAM_POINT_SIZE] If enabled, and a vertex shader is active...
If enabled, blend the incoming RGBA color values with the values in the color buffers, see also BlendFunc for more information.
If enabled, dither color components or indices before they are written to the color buffer...
If enabled, add the secondary color value to the computed fragment color.
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
bool Has_Texture_Rectangle
bool Has_Primitive_Instancing
bool Is_OpenGL_Core_Profile
OpenGL: true if the current context has been created with the WGL_CONTEXT_CORE_PROFILE_BIT_ARB or equ...
If enabled, draw points with proper filtering; Otherwise, draw aliased points, see also PointSize...
bool Is_OpenGL_Initialized
Set to true if the last call to vl::initializeOpenGL() was succesful.
If enabled, an offset is added to depth values of a polygon's fragments before the depth comparison i...
If enabled, performs alpha testing, see also AlphaFunc for more information.
If enabled, and if the polygon is rendered in GL_FILL mode, an offset is added to depth values of a p...
If enabled, clip geometry against user-defined half space #5.
Visualization Library main namespace.
bool Has_GLES_Version_2_0
static void bug(const String &message)
Use this function to provide information about programming errors: wrong parameter initialization...
bool Has_Transform_Feedback
bool Has_GLSL_120_Or_More
If enabled, each sample alpha value is replaced by the maximum representable alpha value...
VLGRAPHICS_EXPORT bool initializeOpenGL()
To test whether OpenGL has been initialized at least once check vl::Is_OpenGL_Initialized.
If enabled, clip geometry against user-defined half space #2.
If enabled, draw lines with correct filtering; Otherwise, draw aliased lines, see also LineWidth...
VL_COMPILE_TIME_CHECK(sizeof(i8) *8==8)
bool Has_GL_GENERATE_MIPMAP
#define CONTEXT_PROFILE_MASK
If enabled, compute a temporary coverage value where each bit is determined by the alpha value at the...
If enabled, calculate texture coordinates for points based on texture environment and point parameter...
If enabled, apply the currently selected logical operation to the incoming RGBA color and color buffe...
If enabled, clip geometry against user-defined half space #0.
If enabled, blend a fog color into the post-texturing color, see also Fog.
VLGRAPHICS_EXPORT const char * getGLErrorString(int err)
Returns a readable string corresponding to the given OpenGL error code as returned by glGetError() ...
If enabled, use multiple fragment samples in computing the final color of a pixel.
bool Has_GLSL_330_Or_More
If enabled, and a vertex shader is active, it specifies that the GL will choose between front and bac...
If enabled, do stencil testing and update the stencil buffer, see also StencilFunc and StencilOp...
bool Has_GLSL_130_Or_More
If enabled, clip geometry against user-defined half space #6.
bool Has_Fixed_Function_Pipeline
OpenGL: true if !Is_OpenGL_Forward_Compatible && !Is_OpenGL_Core_Profile OpenGL ES 1: always true Ope...
bool Has_Primitive_Restart
bool Is_Enable_Supported[EN_EnableCount]
If enabled, cubemap textures are sampled such that when linearly sampling from the border between two...
If enabled, the fragment's coverage is ANDed with the temporary coverage value; If GL_SAMPLE_COVERAGE...
If enabled, draw polygons with proper filtering; Otherwise, draw aliased polygons; For correct antial...
If enabled, normals are scaled by a scaling factor derived from the modelview matrix; vl::EN_RESCALE_...
If enabled, normal vectors are scaled to unit length after transformation, see also vl::EN_RESCALE_NO...
If enabled, and if the polygon is rendered in GL_LINE mode, an offset is added to depth values of a p...
If enabled, clip geometry against user-defined half space #3.
If enabled, use the current line stipple pattern when drawing lines, see also LineStipple.
If enabled, cull polygons based on their winding in window coordinates, see also CullFace.
If enabled, clip geometry against user-defined half space #4.