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