Tulip 5.7.1
Large graphs analysis and drawing
Loading...
Searching...
No Matches
OpenGlConfigManager.h
1/*
2 *
3 * This file is part of Tulip (https://tulip.labri.fr)
4 *
5 * Authors: David Auber and the Tulip development Team
6 * from LaBRI, University of Bordeaux
7 *
8 * Tulip is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation, either version 3
11 * of the License, or (at your option) any later version.
12 *
13 * Tulip is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
17 *
18 */
19///@cond DOXYGEN_HIDDEN
20
21#ifndef Tulip_OPENGLCONFIGMANAGER_H
22#define Tulip_OPENGLCONFIGMANAGER_H
23
24#include <tulip/tulipconf.h>
25
26#include <string>
27#include <unordered_map>
28
29#define BUFFER_OFFSET(bytes) (reinterpret_cast<GLubyte *>(bytes))
30
31namespace tlp {
32
33/**
34 *
35 * Used to manage OpenGl configuration
36 */
37class TLP_GL_SCOPE OpenGlConfigManager {
38
39public:
40 /**
41 * Returns the OpenGL version number supported by the host system as a string.
42 *
43 * \since Tulip 5.0
44 */
45 static std::string getOpenGLVersionString();
46
47 /**
48 * Returns the OpenGL version number supported by the host system as a number.
49 */
50 static double getOpenGLVersion();
51
52 /**
53 * Return the vendor name of the OpenGL driver installed on the host system.
54 */
55 static std::string getOpenGLVendor();
56
57 static void initExtensions();
58
59 /**
60 * Checks if an OpenGL extension is supported by the driver installed on the host system.
61 * \param extensionName the name of the OpenGL extension to check in the form "GL_.*" (for
62 * instance "GL_ARB_vertex_buffer_object")
63 */
64 static bool isExtensionSupported(const std::string &extensionName);
65
66 /**
67 * Returns if vertex buffer objects can be used on the host system.
68 */
69 static bool hasVertexBufferObject();
70
71 /**
72 * Enables / disables anti-aliasing rendering.
73 */
74 static void setAntiAliasing(const bool antialiasing) {
75 _antialiased = antialiasing;
76 }
77
78 /**
79 * Returns the anti-aliasing state
80 */
81 static bool antiAliasing() {
82 return _antialiased;
83 }
84
85 /**
86 * Activates anti-aliasing
87 * This method has no effect if anti-aliasing has been disabled by a call to
88 * setAntiAliasing(false).
89 */
90 static void activateAntiAliasing();
91
92 /**
93 * Deactivates anti-aliasing
94 * This method has no effect if anti-aliasing has been disabled by a call to
95 * setAntiAliasing(false).
96 */
97 static void deactivateAntiAliasing();
98
99 /**
100 * Returns a maximum number of samples for anti-aliasing based on graphics hardware capability
101 *
102 */
103 static int maxNumberOfSamples();
104
105private:
106 static bool _glewIsInit;
107 static bool _antialiased;
108 static std::unordered_map<std::string, bool> _checkedExtensions;
109};
110} // namespace tlp
111
112#endif
113///@endcond