Tulip  4.2.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 <cassert>
25 #include <iostream>
26 #include <map>
27 
28 #if defined(_MSC_VER)
29 #include <Windows.h>
30 #endif
31 
32 #if defined(__APPLE__)
33 #include <OpenGL/gl.h>
34 #include <OpenGL/glu.h>
35 #else
36 #include <GL/gl.h>
37 #include <GL/glu.h>
38 # if defined(__WIN32__)
39 # include <GL/glext.h>
40 # endif
41 #endif
42 
43 #include <tulip/tulipconf.h>
44 
45 #define BUFFER_OFFSET(bytes) ((GLubyte*) NULL + (bytes))
46 
47 namespace tlp {
48 
49 /** \brief Singleton used to manage OpenGl configuration
50  *
51  * Singleton used to manage OpenGl configuration
52  */
53 class TLP_GL_SCOPE OpenGlConfigManager {
54 
55 public:
56 
57  /**
58  * Return the current instance. If instance doesn't exist, create it.
59  */
60  static OpenGlConfigManager &getInst();
61 
62  /**
63  * Check if system has good graphics card drivers.
64  */
65  void checkDrivers();
66 
67  /**
68  * Returns the OpenGL version number supported by the host system.
69  */
70  double getOpenGLVersion();
71 
72  /**
73  * Return the vendor name of the OpenGL driver installed on the host system.
74  */
75  std::string getOpenGLVendor();
76 
77  /**
78  * Checks if an OpenGL extension is supported by the driver installed on the host system.
79  * \param extensionName the name of the OpenGL extension to check in the form "GL_.*" (for instance "GL_ARB_vertex_buffer_object")
80  */
81  bool isExtensionSupported(const std::string &extensionName);
82 
83  /**
84  * Returns if vertex buffer objects can be used on the host system.
85  */
86  bool hasVertexBufferObject();
87 
88  /**
89  * Enables / disables anti-aliasing rendering.
90  */
91  void setAntiAliasing(const bool antialiasing) {
92  antialiased = antialiasing;
93  }
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  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  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  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  void desactivatePolygonAntiAliasing();
117 
118  void initGlew();
119 
120 private:
121 
122 
123 
124  /**
125  * Private constructor for singleton
126  */
127  OpenGlConfigManager();
128 
129  static OpenGlConfigManager* inst;
130 
131  bool glewIsInit;
132  bool driversAreChecked;
133  bool antialiased;
134 
135  std::map<std::string, bool> checkedExtensions;
136 
137 };
138 
139 }
140 
141 #endif
142 ///@endcond