Tulip  4.1.0
Better Visualization Through Research
 All Classes 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 #ifdef HAVE_CONFIG_H
44 #include <config.h>
45 #endif
46 
47 #include <tulip/tulipconf.h>
48 
49 #define BUFFER_OFFSET(bytes) ((GLubyte*) NULL + (bytes))
50 
51 namespace tlp {
52 
53 /** \brief Singleton used to manage OpenGl configuration
54  *
55  * Singleton used to manage OpenGl configuration
56  */
57 class TLP_GL_SCOPE OpenGlConfigManager {
58 
59 public:
60 
61  /**
62  * Return the current instance. If instance doesn't exist, create it.
63  */
64  static OpenGlConfigManager &getInst();
65 
66  /**
67  * Check if system has good graphics card drivers.
68  */
69  void checkDrivers();
70 
71  /**
72  * Returns the OpenGL version number supported by the host system.
73  */
74  double getOpenGLVersion();
75 
76  /**
77  * Return the vendor name of the OpenGL driver installed on the host system.
78  */
79  std::string getOpenGLVendor();
80 
81  /**
82  * Checks if an OpenGL extension is supported by the driver installed on the host system.
83  * \param extensionName the name of the OpenGL extension to check in the form "GL_.*" (for instance "GL_ARB_vertex_buffer_object")
84  */
85  bool isExtensionSupported(const std::string &extensionName);
86 
87  /**
88  * Returns if vertex buffer objects can be used on the host system.
89  */
90  bool hasVertexBufferObject();
91 
92  /**
93  * Enables / disables anti-aliasing rendering.
94  */
95  void setAntiAliasing(const bool antialiasing) {
96  antialiased = antialiasing;
97  }
98 
99  /**
100  * Activates the anti-aliasing of lines and points primitives.
101  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
102  */
103  void activateLineAndPointAntiAliasing();
104 
105  /**
106  * Desactivates the anti-aliasing of lines and points primitives.
107  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
108  */
109  void desactivateLineAndPointAntiAliasing();
110 
111  /**
112  * Activates the anti-aliasing of polygons primitives.
113  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
114  */
115  void activatePolygonAntiAliasing();
116  /**
117  * Desactivates the anti-aliasing of polygons primitives.
118  * This method has no effect if anti-aliasing has been disabled by a call to setAntiAliasing(false).
119  */
120  void desactivatePolygonAntiAliasing();
121 
122  void initGlew();
123 
124 private:
125 
126 
127 
128  /**
129  * Private constructor for singleton
130  */
131  OpenGlConfigManager();
132 
133  static OpenGlConfigManager* inst;
134 
135  bool glewIsInit;
136  bool driversAreChecked;
137  bool antialiased;
138 
139  std::map<std::string, bool> checkedExtensions;
140 
141 };
142 
143 }
144 
145 #endif
146 ///@endcond