Tulip  4.1.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
GlDisplayListManager.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_GLDISPLAYLISTMANAGER_H
22 #define Tulip_GLDISPLAYLISTMANAGER_H
23 
24 #include <map>
25 #include <cassert>
26 #include <string>
27 
28 #include <tulip/OpenGlConfigManager.h>
29 
30 #include <tulip/tulipconf.h>
31 
32 namespace tlp {
33 
34 /** \brief Singleton used to manage OpenGl display list
35  *
36  * Singleton used to manage OpenGl display list.
37  * First createInst must be call.
38  */
39 class TLP_GL_SCOPE GlDisplayListManager {
40 
41  typedef std::map<std::string,GLuint> DisplayListMap;
42  typedef std::map<unsigned long, DisplayListMap> ContextAndDisplayListMap;
43 
44 public:
45 
46  /**
47  * Return the current instance. If instance doesn't exist, create it.
48  */
49  static GlDisplayListManager &getInst() {
50  if(!inst)
51  inst=new GlDisplayListManager();
52 
53  return *inst;
54  }
55 
56  /**
57  * Change OpenGl context because display list can't be shared in different context
58  */
59  void changeContext(unsigned long context);
60 
61  /**
62  * remove context
63  */
64  void removeContext(unsigned long context);
65 
66  /**
67  * Begin to record a new display list with name : name
68  */
69  bool beginNewDisplayList(const std::string& name);
70  /**
71  * End the current record of display list
72  */
73  void endNewDisplayList();
74 
75  /**
76  * Call display list with name : name
77  */
78  bool callDisplayList(const std::string& name);
79 
80 private:
81 
82  /**
83  * Private constructor for singleton
84  */
85  GlDisplayListManager() {}
86 
87  unsigned long currentContext;
88 
89  static GlDisplayListManager* inst;
90 
91  ContextAndDisplayListMap displayListMap;
92 
93 };
94 
95 }
96 
97 #endif // Tulip_GLDISPLAYLISTMANAGER_H
98 ///@endcond