Tulip  4.7.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
OpenGlConfigManager.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
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 <map>
27 #include <string>
28 
29 #define BUFFER_OFFSET(bytes) ((GLubyte*) NULL + (bytes))
30 
31 namespace tlp {
32 
33 /** \brief Singleton used to manage OpenGl configuration
34  *
35  * Singleton used to manage OpenGl configuration
36  */
37 class TLP_GL_SCOPE OpenGlConfigManager {
38 
39 public:
40 
41  /**
42  * Return the current instance. If instance doesn't exist, create it.
43  */
44  static OpenGlConfigManager &getInst();
45 
46  /**
47  * Returns the OpenGL version number supported by the host system.
48  */
49  double getOpenGLVersion();
50 
51  /**
52  * Return the vendor name of the OpenGL driver installed on the host system.
53  */
54  std::string getOpenGLVendor();
55 
56  void initExtensions();
57 
58  /**
59  * Checks if an OpenGL extension is supported by the driver installed on the host system.
60  * \param extensionName the name of the OpenGL extension to check in the form "GL_.*" (for instance "GL_ARB_vertex_buffer_object")
61  */
62  bool isExtensionSupported(const std::string &extensionName);
63 
64  /**
65  * Returns if vertex buffer objects can be used on the host system.
66  */
67  bool hasVertexBufferObject();
68 
69  /**
70  * Enables / disables anti-aliasing rendering.
71  */
72  void setAntiAliasing(const bool antialiasing) {
73  antialiased = antialiasing;
74  }
75 
76  /**
77  * Returns the anti-aliasing state
78  */
79  bool antiAliasing() const {
80  return antialiased;
81  }
82 
83  /**
84  * Activates anti-aliasing
85  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
86  */
87  void activateAntiAliasing();
88 
89  /**
90  * Desactivates anti-aliasing
91  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
92  */
93  void desactivateAntiAliasing();
94 
95  /**
96  * Activates the anti-aliasing of lines and points primitives.
97  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
98  */
99  _DEPRECATED void activateLineAndPointAntiAliasing();
100 
101  /**
102  * Desactivates the anti-aliasing of lines and points primitives.
103  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
104  */
105  _DEPRECATED void desactivateLineAndPointAntiAliasing();
106 
107  /**
108  * Activates the anti-aliasing of polygons primitives.
109  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
110  */
111  _DEPRECATED void activatePolygonAntiAliasing();
112  /**
113  * Desactivates the anti-aliasing of polygons primitives.
114  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
115  */
116  _DEPRECATED void desactivatePolygonAntiAliasing();
117 
118 private:
119 
120  /**
121  * Private constructor for singleton
122  */
123  OpenGlConfigManager();
124 
125  static OpenGlConfigManager* inst;
126 
127  bool glewIsInit;
128  bool driversAreChecked;
129  bool antialiased;
130 
131  std::map<std::string, bool> checkedExtensions;
132 
133 };
134 
135 }
136 
137 #endif
138 ///@endcond