Tulip  4.4.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 1 and Inria Bordeaux - Sud Ouest
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  /**
57  * Checks if an OpenGL extension is supported by the driver installed on the host system.
58  * \param extensionName the name of the OpenGL extension to check in the form "GL_.*" (for instance "GL_ARB_vertex_buffer_object")
59  */
60  bool isExtensionSupported(const std::string &extensionName);
61 
62  /**
63  * Returns if vertex buffer objects can be used on the host system.
64  */
65  bool hasVertexBufferObject();
66 
67  /**
68  * Enables / disables anti-aliasing rendering.
69  */
70  void setAntiAliasing(const bool antialiasing) {
71  antialiased = antialiasing;
72  }
73 
74  /**
75  * Activates the anti-aliasing of lines and points primitives.
76  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
77  */
78  void activateLineAndPointAntiAliasing();
79 
80  /**
81  * Desactivates the anti-aliasing of lines and points primitives.
82  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
83  */
84  void desactivateLineAndPointAntiAliasing();
85 
86  /**
87  * Activates the anti-aliasing of polygons primitives.
88  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
89  */
90  void activatePolygonAntiAliasing();
91  /**
92  * Desactivates the anti-aliasing of polygons primitives.
93  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
94  */
95  void desactivatePolygonAntiAliasing();
96 
97  void initExtensions();
98 
99 private:
100 
101  /**
102  * Private constructor for singleton
103  */
104  OpenGlConfigManager();
105 
106  static OpenGlConfigManager* inst;
107 
108  bool glewIsInit;
109  bool driversAreChecked;
110  bool antialiased;
111 
112  std::map<std::string, bool> checkedExtensions;
113 
114 };
115 
116 }
117 
118 #endif
119 ///@endcond