![]() |
Tulip
4.6.0
Better Visualization Through Research
|
00001 /* 00002 * 00003 * This file is part of Tulip (www.tulip-software.org) 00004 * 00005 * Authors: David Auber and the Tulip development Team 00006 * from LaBRI, University of Bordeaux 00007 * 00008 * Tulip is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation, either version 3 00011 * of the License, or (at your option) any later version. 00012 * 00013 * Tulip is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 * See the GNU General Public License for more details. 00017 * 00018 */ 00019 ///@cond DOXYGEN_HIDDEN 00020 00021 #ifndef Tulip_QGLBUFFERMANAGER_H 00022 #define Tulip_QGLBUFFERMANAGER_H 00023 00024 #include <map> 00025 00026 #include <tulip/tulipconf.h> 00027 00028 class QGLPixelBuffer; 00029 class QGLFramebufferObject; 00030 00031 namespace tlp { 00032 00033 /** \brief Class to manage QGlPixelBuffer and QGlFramebufferObject 00034 * Singleton class to manager QGlPixelBuffer and QGlFramebufferObject 00035 */ 00036 class TLP_QT_SCOPE QGlBufferManager { 00037 00038 public: 00039 00040 /** 00041 * Return the QGlBuffer manager singleton, il singleton doesn't exist this function create it 00042 */ 00043 static QGlBufferManager &getInst() { 00044 if(!inst) 00045 inst=new QGlBufferManager(); 00046 00047 return *inst; 00048 } 00049 00050 static void clearBuffers(); 00051 00052 /** 00053 * Return if QGlPixelBuffer can be used 00054 */ 00055 bool canUsePixelBuffer() { 00056 return pixelBufferWork; 00057 } 00058 00059 /** 00060 * Return if QGlFramebufferObject can be used 00061 */ 00062 bool canUseFramebufferObject() { 00063 return framebufferObjectWork; 00064 } 00065 00066 /** 00067 * Return a QGlPixelBuffer with given size 00068 */ 00069 QGLPixelBuffer *getPixelBuffer(int width, int height); 00070 00071 /** 00072 * Return a QGLFramebufferObject with given size 00073 */ 00074 QGLFramebufferObject *getFramebufferObject(int width, int height); 00075 00076 private: 00077 00078 /** 00079 * empty private constructor for singleton 00080 */ 00081 QGlBufferManager(); 00082 00083 static QGlBufferManager* inst; 00084 00085 std::map<std::pair<int,int>,QGLPixelBuffer*> widthHeightToBuffer; 00086 std::map<QGLPixelBuffer*,std::pair<int,int> > bufferToWidthHeight; 00087 std::map<std::pair<int,int>,QGLFramebufferObject*> widthHeightToFramebuffer; 00088 std::map<QGLFramebufferObject*,std::pair<int,int> > framebufferToWidthHeight; 00089 00090 bool pixelBufferWork; 00091 bool framebufferObjectWork; 00092 00093 }; 00094 00095 } 00096 00097 #endif // Tulip_QGLBUFFERMANAGER_H 00098 ///@endcond