MeVisLab Resolution Independence API
mlOpenGL.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_OPENGL_H
14 #define ML_OPENGL_H
15 
16 
18 
19 #include "mlOpenGLSystem.h"
20 
21 #ifdef _MSC_VER
22 #pragma warning( push )
23 // suppress warning that is irrelevant for private static members:
24 #pragma warning(disable : 4251 ) // class 'std::string' needs to have dll-interface to be used by clients of class 'ml::OpenGL'
25 #endif
26 
27 // include the glew header, which allows to access the whole OpenGL and extensions API
28 // without using native windows or unix headers
29 #include <GL/glew.h>
30 #include <cstdio>
31 #include <string>
32 
33 ML_OPENGL_START_NAMESPACE
34 
36 
59 {
60 public:
62  static bool init();
63 
65  static const std::string& getVendorString();
66 
68  static const std::string& getRendererString();
69 
71  static const std::string& getVersionString();
72 
74  static bool isMesaSoftwareRenderer() { return _isMesaSoftwareRenderer; }
75 
77  static bool supports10Bit() { return _supports10Bit; }
78 
81 
83  static bool supportsPBO();
84 
91  static GLint getVideoMemorySizeInMB();
92 
94  static GLint getMaxTextureSize();
95 
97  static GLint getMaxTextureSize3D();
98 
100  static GLint getMaxTextureImageUnits();
101 
103  static GLint getMaxVertexAttributes();
104 
106  static GLint getMaxVaryingFloats();
107 
109  static GLint getMaxSmoothLineWidth();
110 
112  static GLint getMaxClipPlanes();
113 
115  static GLint getMaxLights();
116 
118  static bool isSupported(const char* extension);
119 
126 
128  static void disableAllClipPlanes();
129 
131  static void disableAllLights();
132 
134  static std::string uniformTypeToString(GLenum type);
135 
137  static std::string getUniformValue(GLint program, GLint uniform, GLenum type);
138 
140  struct TypeInfo {
141  TypeInfo(const std::string& aType, const std::string& aName,
142  const std::string& aValue = std::string(),
143  const std::string& aSize = std::string()) {
144  this->type = aType;
145  this->name = aName;
146  this->value = aValue;
147  this->size = aSize;
148  };
149  std::string name;
150  std::string type;
151  std::string value;
152  std::string size;
153  };
154 
156  static void getActiveUniforms(GLuint program, std::vector<TypeInfo>& uniforms, bool withValues);
157 
159  static const char* internalFormatToString( GLuint format );
160 
161 private:
162  static GLint _videoMemorySizeInMB;
163  static GLint _maxGLTextureSize;
164  static GLint _maxGLTextureSize3D;
165  static GLint _maxTextureImageUnits;
166  static GLint _maxVertexAttributes;
167  static GLint _maxVaryingFloats;
168  static GLint _maxSmoothLineWidth;
169  static GLint _maxClipPlanes;
170  static GLint _maxLights;
171  static bool _supportsRenderTo3DTexture;
172  static bool _supports10Bit;
173  static bool _isMesaSoftwareRenderer;
174 
175  static void queryCapabilities();
176  static void detect10BitCapability();
177  static void queryVideoMemorySize();
178 
181  static bool hardwareSupports10BitContext();
182 
183  static std::string getGLString(int name);
184 
185  static std::string _vendor;
186  static std::string _renderer;
187  static std::string _version;
188 
189 };
190 
191 ML_OPENGL_END_NAMESPACE
192 
193 #ifdef _MSC_VER
194 #pragma warning( pop )
195 #endif
196 
197 
198 #endif
MeVis OpenGL Information Interface (Singleton)
Definition: mlOpenGL.h:59
static bool isSupported(const char *extension)
check if the given extension is supported
static GLint getMaxClipPlanes()
returns max number of clip planes
static bool supportsRenderTo3DTexture()
Returns if rendering to 3D textures is supported by FrameBufferObjects.
static const std::string & getVersionString()
get the open gl version string
static GLint getVideoMemorySizeInMB()
Returns the maximum available video memory size in MB.
static void disableAllClipPlanes()
disables all clip planes (needs a valid OpenGL context!)
static bool isMesaSoftwareRenderer()
returns if the OpenGL driver is the Mesa software renderer (typically llvmpipe).
Definition: mlOpenGL.h:74
static GLint getMaxTextureSize()
returns max 2d texture size (using GL_MAX_TEXTURE_SIZE)
static void getActiveUniforms(GLuint program, std::vector< TypeInfo > &uniforms, bool withValues)
Get the active uniforms from a shader.
static GLint getMaxLights()
returns max number of lights
static GLint getMaxTextureImageUnits()
returns max available texture units (using GL_MAX_TEXTURE_IMAGE_UNITS)
static std::string getUniformValue(GLint program, GLint uniform, GLenum type)
Get uniform value as string.
static GLint getMaxVertexAttributes()
returns max available vertex attributes (using GL_MAX_VERTEX_ATTRIBS)
static bool init()
initialize the OpenGL information and GLEW, returns true if everything is ok
static bool supportsPBO()
Returns if PixelBufferObjects are supported.
static const char * internalFormatToString(GLuint format)
Returns the internal GL format as string;.
static const std::string & getVendorString()
get the open gl vendor string
static const std::string & getRendererString()
get the open gl driver string
static GLint getMaxTextureSize3D()
returns max 3d texture size (using GL_MAX_3D_TEXTURE_SIZE)
static std::string uniformTypeToString(GLenum type)
Get uniform type as string.
static GLint getMaxVaryingFloats()
returns max available varying floats ( using GL_MAX_VARYING_FLOATS )
static void disableAllLights()
disables all lights (needs a valid OpenGL context!)
static bool supports10Bit()
returns if the OpenGL driver supports visible 10bit OpenGL contexts.
Definition: mlOpenGL.h:77
static GLint getMaxSmoothLineWidth()
returns max size of a supported smooth line width
static void clearTextureUnitsAndShaders()
this method binds the 0 target to all texture units and ARB/GLSL shaders and it should be called in c...
#define MLOPENGL_EXPORT
Macro to put all following stuff into the namespace ML_NAMESPACE to avoid collisions with symbols of ...
Struct to store infos about a type, e.g. about a uniform.
Definition: mlOpenGL.h:140
std::string size
Definition: mlOpenGL.h:152
std::string name
Definition: mlOpenGL.h:148
std::string type
Definition: mlOpenGL.h:150
std::string value
Definition: mlOpenGL.h:151
TypeInfo(const std::string &aType, const std::string &aName, const std::string &aValue=std::string(), const std::string &aSize=std::string())
Definition: mlOpenGL.h:141