| VRS - The Virtual Rendering System |
| version 3.3 |
00001 /****************************************************************************** 00002 * VRS - The Virtual Rendering System 00003 * Copyright (C) 2002 Computer Graphics Systems Group at the 00004 * Hasso-Plattner-Institute (HPI), Potsdam, Germany. 00005 * 00006 * This library is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 2.1 of the License, or (at 00009 * your option) any later version. This library is distributed in the hope 00010 * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 00011 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU Lesser General Public License for more details. You should have received 00013 * a copy of the GNU Lesser+ General Public License along with this library; if 00014 * not, write to the FreeSoftware Foundation, Inc., 59 Temple Place, Suite 330, 00015 * Boston, MA, 02111-1307, USA. 00016 ******************************************************************************/ 00017 00018 // $Id: pbuffermanagergl.h 6014 2007-08-09 07:51:16Z Konstantin_Baumann $ 00019 // $Date: 2007-08-09 09:51:16 +0200 (Thu, 09 Aug 2007) $ 00020 // $Revision: 6014 $ 00021 // $State$ 00022 // $Author: Konstantin_Baumann $ 00023 // 00024 // $Log$ 00025 // Revision 1.18 2005/01/03 01:43:09 klimetschek 00026 // - modified win32 project layout, splitted vrs.vcproj into vrs_container, vrs_core, vrs_sg, vrs_image, vrs_opengl and vrs_io 00027 // - removed vrs.vcproj 00028 // minor things: 00029 // - added all glutexamples to vrs4glut.sln 00030 // - fixed some problems in glutexamples 00031 // - removed all project references from all VS projects (using solution wide project dependencies instead) 00032 // 00033 // Revision 1.17 2004/11/03 14:45:06 saar 00034 // Class comment changed (Doxygen style) 00035 // 00036 // Revision 1.16 2004/05/06 15:06:03 kirsch 00037 // code cleanup. keys are now of type sharedobj *const instead of const sharedobj* 00038 // 00039 // Revision 1.15 2004/03/12 16:28:40 baumann 00040 // macros VRS_NAMESPACE_BEGIN/_END expanded and removed 00041 // 00042 // Revision 1.14 2004/01/19 11:43:58 baumann 00043 // serialization mechanism improved 00044 // 00045 // Revision 1.13 2004/01/19 07:28:02 baumann 00046 // serialization mechanism improved 00047 // 00048 // Revision 1.12 2003/11/07 14:19:25 kirsch 00049 // removed leading underscore from include guards 00050 // 00051 // Revision 1.11 2003/02/14 10:32:31 baumann 00052 // parameter "void" removed from argument list (due to iVRS) 00053 // 00054 // Revision 1.10 2003/02/13 14:38:46 kirsch 00055 // added static structure that ensures that during program termination, 00056 // pbuffers get deleted (there was a cyclic dependency before). This 00057 // feature is currently deactivated due to upshowing error when a program 00058 // terminates, which cannot (glut?) or will hopefully (tcl, others?) be fixed. 00059 // 00060 // Revision 1.9 2002/11/23 12:05:30 kirsch 00061 // changed enum values to uppercase 00062 // 00063 // Revision 1.8 2002/11/22 10:33:01 kirsch 00064 // added updateTextureArea 00065 // 00066 // Revision 1.7 2002/10/28 14:21:56 kirsch 00067 // made some methods const, others static 00068 // 00069 // Revision 1.6 2002/10/28 12:53:30 kirsch 00070 // updated comment 00071 // 00072 // Revision 1.5 2002/10/28 12:37:08 kirsch 00073 // moved creation of pbuffermanager to shared context 00074 // removed engine and context attribute from pbuffermanager 00075 // instead the engine is given as argument 00076 // 00077 // Revision 1.4 2002/10/28 10:01:22 kirsch 00078 // bug fixes for CanvasSize-setting. match() revised. Comments updated. 00079 // 00080 // Revision 1.3 2002/10/27 16:56:51 kirsch 00081 // store pbuffers instead of indices in key-dictionary, since the latter might change 00082 // 00083 // Revision 1.2 2002/10/25 14:44:38 kirsch 00084 // added creation and retrieval of pbuffers with sharedobj-keys 00085 // 00086 // Revision 1.1 2002/10/24 09:45:38 kirsch 00087 // added PBufferManagerGL 00088 // 00089 00090 #ifndef VRS_OPENGL_PBUFFERMANAGERGL_H_ 00091 #define VRS_OPENGL_PBUFFERMANAGERGL_H_ 00092 00093 #include <vrs/sharedobj.h> 00094 #include <vrs/container/array.h> 00095 #include <vrs/opengl/glcanvas.h> 00096 #include <map> 00097 #include <stack> 00098 00099 namespace VRS { 00100 00101 class EngineGL; 00102 class SharedContextGL; 00103 class PBufferCanvasGL; 00104 class Texture2DGL; 00105 00117 class VRS_CORE_API PBufferManagerGL : public SharedObj { 00118 public: 00119 00120 enum PBufferSizePolicy { 00121 CANVAS_SIZE, 00122 FIXED_SIZE 00123 }; 00124 VRS_SERIALIZABLE_CLASS_ENUM(PBufferSizePolicy); 00125 00126 PBufferCanvasGL* reserve(EngineGL* engine, 00127 PBufferManagerGL::PBufferSizePolicy = PBufferManagerGL::CANVAS_SIZE, 00128 unsigned int width = 0, unsigned int height = 0, 00129 GLCanvas::CanvasProperties = GLCanvas::RGBADS); 00144 PBufferCanvasGL* reserve(EngineGL* engine, SharedObj *const key, 00145 PBufferManagerGL::PBufferSizePolicy = PBufferManagerGL::CANVAS_SIZE, 00146 unsigned int width = 0, unsigned int height = 0, 00147 GLCanvas::CanvasProperties = GLCanvas::RGBADS); 00164 PBufferCanvasGL* get(SharedObj *const key) const; 00169 void free(PBufferCanvasGL*); 00175 void free(SharedObj *const key); 00183 static void prepareContext(EngineGL*, PBufferCanvasGL*); 00191 static void releaseContext(EngineGL*, PBufferCanvasGL*); 00195 void updateTextureArea(EngineGL*, PBufferCanvasGL*, Texture2DGL*, Area = Area(0, 0, 0, 0)); 00206 void setCleanUpAtTermination(bool); 00211 bool getCleanUpAtTermination() const; 00215 void unconditionalCleanUp(); 00219 static void cleanUp(); 00225 VRS_TYPEINFO(PBufferManagerGL, SharedObj); 00226 00227 protected: 00228 00229 friend class SharedContextGL; 00230 PBufferManagerGL(); 00232 ~PBufferManagerGL(); 00233 00234 void perFrameCleanUp(const unsigned int framesBeforeDestruction = 20); 00240 private: 00241 00242 int find( 00243 PBufferManagerGL::PBufferSizePolicy, 00244 unsigned int width, unsigned int height, 00245 GLCanvas::CanvasProperties) const; 00250 unsigned int match(PBufferCanvasGL*, 00251 PBufferManagerGL::PBufferSizePolicy, 00252 unsigned int width, unsigned int height, 00253 GLCanvas::CanvasProperties) const; 00261 static GLCanvas* getContext(EngineGL*); 00266 SO<NonPersistentArray<SO<PBufferCanvasGL> > > m_pbuffer; 00267 00268 enum UseFlag { UF_True = 1 }; 00269 SO<NonPersistentArray<int> > m_inUse; 00270 00271 mutable std::map<SharedObj *const, std::stack<PBufferCanvasGL*> > m_objToPBufferMap; 00272 // key - stack of int dictionary. Note that we do not use 00273 // an SO<const SharedObj>, since the SharedObj are never dereferenced 00274 // anyway. Also the PBufferCanvasGL-Objects do not need to be 00275 // shared objects, since only pbuffer that are in the pbuffer- 00276 // array (m_pbuffer) can be included in the dictionary, and these 00277 // are shared. 00278 00279 bool m_cleanUpAtTermination; 00280 }; 00281 00282 } // namespace VRS 00283 00284 #endif // VRS_OPENGL_PBUFFERMANAGERGL_H_