Tulip  5.1.0
Large graphs analysis and drawing
OpenGlConfigManager.h
1 /*
2  *
3  * This file is part of Tulip (http://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 <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  */
45  static OpenGlConfigManager &getInst();
46 
47  /**
48  * Returns the OpenGL version number supported by the host system as a string.
49  *
50  * \since Tulip 5.0
51  */
52  std::string getOpenGLVersionString() const;
53 
54  /**
55  * Returns the OpenGL version number supported by the host system as a number.
56  */
57  double getOpenGLVersion() const;
58 
59  /**
60  * Return the vendor name of the OpenGL driver installed on the host system.
61  */
62  std::string getOpenGLVendor() const;
63 
64  void initExtensions();
65 
66  /**
67  * Checks if an OpenGL extension is supported by the driver installed on the host system.
68  * \param extensionName the name of the OpenGL extension to check in the form "GL_.*" (for instance "GL_ARB_vertex_buffer_object")
69  */
70  bool isExtensionSupported(const std::string &extensionName);
71 
72  /**
73  * Returns if vertex buffer objects can be used on the host system.
74  */
75  bool hasVertexBufferObject();
76 
77  /**
78  * Enables / disables anti-aliasing rendering.
79  */
80  void setAntiAliasing(const bool antialiasing) {
81  antialiased = antialiasing;
82  }
83 
84  /**
85  * Returns the anti-aliasing state
86  */
87  bool antiAliasing() const {
88  return antialiased;
89  }
90 
91  /**
92  * Activates anti-aliasing
93  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
94  */
95  void activateAntiAliasing();
96 
97  /**
98  * Desactivates anti-aliasing
99  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
100  */
101  void desactivateAntiAliasing();
102 
103  /**
104  * Returns a maximum number of samples for anti-aliasing based on graphics hardware capability
105  *
106  */
107  int maxNumberOfSamples() const;
108 
109  /**
110  * Activates the anti-aliasing of lines and points primitives.
111  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
112  */
113  _DEPRECATED void activateLineAndPointAntiAliasing();
114 
115  /**
116  * Desactivates the anti-aliasing of lines and points primitives.
117  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
118  */
119  _DEPRECATED void desactivateLineAndPointAntiAliasing();
120 
121  /**
122  * Activates the anti-aliasing of polygons primitives.
123  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
124  */
125  _DEPRECATED void activatePolygonAntiAliasing();
126  /**
127  * Desactivates the anti-aliasing of polygons primitives.
128  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
129  */
130  _DEPRECATED void desactivatePolygonAntiAliasing();
131 
132 private:
133 
134  /**
135  * Private constructor for singleton
136  */
137  OpenGlConfigManager();
138 
139  static OpenGlConfigManager* inst;
140 
141  bool glewIsInit;
142  bool antialiased;
143 
144  std::map<std::string, bool> checkedExtensions;
145 
146 };
147 
148 }
149 
150 #endif
151 ///@endcond