Tulip  4.7.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
QGlBufferManager.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
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_QGLBUFFERMANAGER_H
22 #define Tulip_QGLBUFFERMANAGER_H
23 
24 #include <map>
25 
26 #include <tulip/tulipconf.h>
27 
28 class QGLPixelBuffer;
29 class QGLFramebufferObject;
30 
31 namespace tlp {
32 
33 /** \brief Class to manage QGlPixelBuffer and QGlFramebufferObject
34  * Singleton class to manager QGlPixelBuffer and QGlFramebufferObject
35  */
36 class TLP_QT_SCOPE QGlBufferManager {
37 
38 public:
39 
40  /**
41  * Return the QGlBuffer manager singleton, il singleton doesn't exist this function create it
42  */
43  static QGlBufferManager &getInst() {
44  if(!inst)
45  inst=new QGlBufferManager();
46 
47  return *inst;
48  }
49 
50  static void clearBuffers();
51 
52  /**
53  * Return if QGlPixelBuffer can be used
54  */
55  bool canUsePixelBuffer() {
56  return pixelBufferWork;
57  }
58 
59  /**
60  * Return if QGlFramebufferObject can be used
61  */
62  bool canUseFramebufferObject() {
63  return framebufferObjectWork;
64  }
65 
66  /**
67  * Return a QGlPixelBuffer with given size
68  */
69  QGLPixelBuffer *getPixelBuffer(int width, int height);
70 
71  /**
72  * Return a QGLFramebufferObject with given size
73  */
74  QGLFramebufferObject *getFramebufferObject(int width, int height);
75 
76 private:
77 
78  /**
79  * empty private constructor for singleton
80  */
81  QGlBufferManager();
82 
83  static QGlBufferManager* inst;
84 
85  std::map<std::pair<int,int>,QGLPixelBuffer*> widthHeightToBuffer;
86  std::map<QGLPixelBuffer*,std::pair<int,int> > bufferToWidthHeight;
87  std::map<std::pair<int,int>,QGLFramebufferObject*> widthHeightToFramebuffer;
88  std::map<QGLFramebufferObject*,std::pair<int,int> > framebufferToWidthHeight;
89 
90  bool pixelBufferWork;
91  bool framebufferObjectWork;
92 
93 };
94 
95 }
96 
97 #endif // Tulip_QGLBUFFERMANAGER_H
98 ///@endcond