MeVisLab Resolution Independence API
Loading...
Searching...
No Matches
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 \
25 : 4251) // class 'std::string' needs to have dll-interface to be used by clients of class 'ml::OpenGL'
26#endif
27
28// Include the GLEW header, which allows to access the entire OpenGL and extensions API
29// without using native Windows or Unix headers
30#include <GL/glew.h>
31#include <cstdio>
32#include <string>
33
34ML_OPENGL_START_NAMESPACE
35
37
60{
61public:
64 static bool init();
65
69
71 static const std::string& getVendorString();
72
74 static const std::string& getRendererString();
75
77 static const std::string& getVersionString();
78
81 {
82 return _isMesaSoftwareRenderer;
83 }
84
86 static bool supports10Bit()
87 {
88 return _supports10Bit;
89 }
90
93
95 static bool supportsPBO();
96
104
106 static GLint getMaxTextureSize();
107
109 static GLint getMaxTextureSize3D();
110
113
116
118 static GLint getMaxVaryingFloats();
119
121 static GLint getMaxSmoothLineWidth();
122
124 static GLint getMaxClipPlanes();
125
127 static GLint getMaxLights();
128
130 static bool isSupported(const char* extension);
131
138
140 static void disableAllClipPlanes();
141
143 static void disableAllLights();
144
146 static std::string uniformTypeToString(GLenum type);
147
149 static std::string getUniformValue(GLint program, GLint uniform, GLenum type);
150
152 struct TypeInfo
153 {
154 TypeInfo(const std::string& aType, const std::string& aName, const std::string& aValue = std::string(),
155 const std::string& aSize = std::string())
156 {
157 this->type = aType;
158 this->name = aName;
159 this->value = aValue;
160 this->size = aSize;
161 };
162 std::string name;
163 std::string type;
164 std::string value;
165 std::string size;
166 };
167
169 static void getActiveUniforms(GLuint program, std::vector<TypeInfo>& uniforms, bool withValues);
170
172 static const char* internalFormatToString(GLuint format);
173
174private:
175 static GLint _videoMemorySizeInMB;
176 static GLint _maxGLTextureSize;
177 static GLint _maxGLTextureSize3D;
178 static GLint _maxTextureImageUnits;
179 static GLint _maxVertexAttributes;
180 static GLint _maxVaryingFloats;
181 static GLint _maxSmoothLineWidth;
182 static GLint _maxClipPlanes;
183 static GLint _maxLights;
184 static bool _supportsRenderTo3DTexture;
185 static bool _supports10Bit;
186 static bool _isMesaSoftwareRenderer;
187
188 static bool _init();
189
190 static void queryCapabilities();
191 static void detect10BitCapability();
192 static void queryVideoMemorySize();
193
196 static bool hardwareSupports10BitContext();
197
198 static std::string getGLString(int name);
199
200 static std::string _vendor;
201 static std::string _renderer;
202 static std::string _version;
203};
204
205ML_OPENGL_END_NAMESPACE
206
207#ifdef _MSC_VER
208#pragma warning(pop)
209#endif
210
211
212#endif
MeVis OpenGL Information Interface (Singleton).
Definition mlOpenGL.h:60
static bool isSupported(const char *extension)
Checks whether the given extension is supported.
static GLint getMaxClipPlanes()
Returns the maximum number of clip planes.
static bool supportsRenderTo3DTexture()
Returns whether rendering to 3D textures is supported by FrameBufferObjects.
static const char * internalFormatToString(GLuint format)
Returns the internal GL format as string;.
static bool initWithExternalContext()
static GLint getVideoMemorySizeInMB()
static const std::string & getVendorString()
Returns the OpenGL vendor string.
static void disableAllClipPlanes()
Disables all clip planes (needs a valid OpenGL context!).
static bool isMesaSoftwareRenderer()
Returns whether the OpenGL driver is the Mesa software renderer (typically llvmpipe).
Definition mlOpenGL.h:80
static GLint getMaxTextureSize()
Returns the maximum 2D texture size (using GL_MAX_TEXTURE_SIZE).
static void getActiveUniforms(GLuint program, std::vector< TypeInfo > &uniforms, bool withValues)
Returns the active uniforms from a shader.
static GLint getMaxLights()
Returns the maximum number of lights.
static GLint getMaxTextureImageUnits()
Returns the maximum available texture units (using GL_MAX_TEXTURE_IMAGE_UNITS).
static std::string getUniformValue(GLint program, GLint uniform, GLenum type)
Returns the uniform value as string.
static GLint getMaxVertexAttributes()
Returns the maximum available vertex attributes (using GL_MAX_VERTEX_ATTRIBS).
static bool init()
static bool supportsPBO()
Returns whether PixelBufferObjects are supported.
static GLint getMaxTextureSize3D()
Returns the maximum 3D texture size (using GL_MAX_3D_TEXTURE_SIZE).
static std::string uniformTypeToString(GLenum type)
Returns the uniform type as string.
static GLint getMaxVaryingFloats()
Returns the maximum available varying floats (using GL_MAX_VARYING_FLOATS).
static void disableAllLights()
Disables all lights (needs a valid OpenGL context!).
static bool supports10Bit()
Returns whether the OpenGL driver supports visible 10-bit OpenGL contexts.
Definition mlOpenGL.h:86
static const std::string & getVersionString()
Return the OpenGL version string.
static GLint getMaxSmoothLineWidth()
Returns the maximum size of a supported smooth line width.
static void clearTextureUnitsAndShaders()
static const std::string & getRendererString()
Returns the OpenGL driver string.
#define MLOPENGL_EXPORT
Closes the namespace for all ML code after the usage of ML_UTILS_START_NAMESPACE.
std::string size
Definition mlOpenGL.h:165
std::string name
Definition mlOpenGL.h:162
std::string type
Definition mlOpenGL.h:163
std::string value
Definition mlOpenGL.h:164
TypeInfo(const std::string &aType, const std::string &aName, const std::string &aValue=std::string(), const std::string &aSize=std::string())
Definition mlOpenGL.h:154