|
Equalizer
1.3.1-git
|
00001 00002 /* Copyright (c) 2007-2011, Stefan Eilemann <eile@equalizergraphics.com> 00003 * 00004 * This library is free software; you can redistribute it and/or modify it under 00005 * the terms of the GNU Lesser General Public License version 2.1 as published 00006 * by the Free Software Foundation. 00007 * 00008 * This library is distributed in the hope that it will be useful, but WITHOUT 00009 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00010 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00011 * details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public License 00014 * along with this library; if not, write to the Free Software Foundation, Inc., 00015 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00016 */ 00017 00018 #ifndef EQUTIL_OBJECTMANAGER_H 00019 #define EQUTIL_OBJECTMANAGER_H 00020 00021 #include <eq/util/types.h> 00022 00023 #include <eq/client/gl.h> // OpenGL/GLEW types 00024 #include <lunchbox/api.h> // EQ_API definition 00025 #include <lunchbox/debug.h> // LBASSERT definition 00026 #include <lunchbox/hash.h> // member 00027 #include <lunchbox/nonCopyable.h> // base class 00028 #include <lunchbox/referenced.h> // base class 00029 00030 namespace eq 00031 { 00032 namespace util 00033 { 00056 template< class T > class ObjectManager : public lunchbox::NonCopyable 00057 { 00058 public: 00059 enum 00060 { 00061 INVALID = 0 //<! return value for failed operations. 00062 }; 00063 00065 EQ_API ObjectManager( const GLEWContext* const glewContext ); 00066 00068 EQ_API ObjectManager( ObjectManager* shared ); 00069 00070 EQ_API virtual ~ObjectManager(); 00071 00073 bool isShared() const { return _data->getRefCount() > 1; } 00074 00075 EQ_API void deleteAll(); 00076 00077 EQ_API GLuint getList( const T& key ) const; 00078 EQ_API GLuint newList( const T& key, const GLsizei num = 1 ); 00079 EQ_API GLuint obtainList( const T& key, const GLsizei num = 1 ); 00080 EQ_API void deleteList( const T& key ); 00081 00082 EQ_API GLuint getTexture( const T& key ) const; 00083 EQ_API GLuint newTexture( const T& key ); 00084 EQ_API GLuint obtainTexture( const T& key ); 00085 EQ_API void deleteTexture( const T& key ); 00086 00087 EQ_API bool supportsBuffers() const; 00088 EQ_API GLuint getBuffer( const T& key ) const; 00089 EQ_API GLuint newBuffer( const T& key ); 00090 EQ_API GLuint obtainBuffer( const T& key ); 00091 EQ_API void deleteBuffer( const T& key ); 00092 00093 EQ_API bool supportsPrograms() const; 00094 EQ_API GLuint getProgram( const T& key ) const; 00095 EQ_API GLuint newProgram( const T& key ); 00096 EQ_API GLuint obtainProgram( const T& key ); 00097 EQ_API void deleteProgram( const T& key ); 00098 00099 EQ_API bool supportsShaders() const; 00100 EQ_API GLuint getShader( const T& key ) const; 00101 EQ_API GLuint newShader( const T& key, const GLenum type ); 00102 EQ_API GLuint obtainShader( const T& key, const GLenum type ); 00103 EQ_API void deleteShader( const T& key ); 00104 00105 EQ_API Accum* getEqAccum( const T& key ) const; 00106 EQ_API Accum* newEqAccum( const T& key ); 00107 EQ_API Accum* obtainEqAccum( const T& key ); 00108 EQ_API void deleteEqAccum( const T& key ); 00109 00110 #ifdef EQUALIZER_SHARED 00111 00112 EQ_API GPUCompressor* getEqUploader( const T& key ) const; 00114 EQ_API GPUCompressor* newEqUploader( const T& key ); 00116 EQ_API GPUCompressor* obtainEqUploader( const T& key ); 00118 EQ_API void deleteEqUploader( const T& key ); 00119 #endif 00120 00121 EQ_API bool supportsEqTexture() const; 00122 EQ_API Texture* getEqTexture( const T& key ) const; 00123 EQ_API Texture* newEqTexture( const T& key, const GLenum target ); 00124 EQ_API Texture* obtainEqTexture( const T& key, const GLenum target ); 00125 EQ_API void deleteEqTexture( const T& key ); 00126 00127 EQ_API bool supportsEqFrameBufferObject() const; 00128 EQ_API FrameBufferObject* getEqFrameBufferObject(const T& key) const; 00129 EQ_API FrameBufferObject* newEqFrameBufferObject( const T& key ); 00130 EQ_API FrameBufferObject* obtainEqFrameBufferObject( const T& key ); 00131 EQ_API void deleteEqFrameBufferObject( const T& key ); 00132 00133 EQ_API bool supportsEqPixelBufferObject() const; 00134 EQ_API PixelBufferObject* getEqPixelBufferObject(const T& key) const; 00135 EQ_API PixelBufferObject* newEqPixelBufferObject( const T& key, 00136 const bool threadSafe ); 00137 EQ_API PixelBufferObject* obtainEqPixelBufferObject( const T& key, 00138 const bool threadSafe ); 00139 EQ_API void deleteEqPixelBufferObject( const T& key ); 00140 00141 EQ_API util::BitmapFont< T >* getEqBitmapFont( const T& key ) const; 00142 EQ_API util::BitmapFont< T >* newEqBitmapFont( const T& key ); 00143 EQ_API util::BitmapFont< T >* obtainEqBitmapFont( const T& key ); 00144 EQ_API void deleteEqBitmapFont( const T& key ); 00145 00146 const GLEWContext* glewGetContext() const { return _data->glewContext; } 00147 00148 private: 00149 struct Object 00150 { 00151 GLuint id; 00152 GLuint num; 00153 }; 00154 00155 typedef stde::hash_map< T, Object > ObjectHash; 00156 typedef stde::hash_map< T, Texture* > TextureHash; 00157 typedef stde::hash_map< T, FrameBufferObject* > FBOHash; 00158 typedef stde::hash_map< T, PixelBufferObject* > PBOHash; 00159 typedef stde::hash_map< T, util::BitmapFont< T >* > FontHash; 00160 typedef stde::hash_map< T, Accum* > AccumHash; 00161 typedef stde::hash_map< T, GPUCompressor* > UploaderHash; 00162 00163 struct SharedData : public lunchbox::Referenced 00164 { 00165 SharedData( const GLEWContext* glewContext ); 00166 virtual ~SharedData(); 00167 00168 GLEWContext* const glewContext; 00169 ObjectHash lists; 00170 ObjectHash textures; 00171 ObjectHash buffers; 00172 ObjectHash programs; 00173 ObjectHash shaders; 00174 ObjectHash uploaderDatas; 00175 AccumHash accums; 00176 TextureHash eqTextures; 00177 FBOHash eqFrameBufferObjects; 00178 PBOHash eqPixelBufferObjects; 00179 FontHash eqFonts; 00180 UploaderHash eqUploaders; 00181 00182 union // placeholder for binary-compatible changes 00183 { 00184 char dummy[64]; 00185 }; 00186 }; 00187 00188 typedef lunchbox::RefPtr< SharedData > SharedDataPtr; 00189 SharedDataPtr _data; 00190 00191 struct Private; 00192 Private* _private; // placeholder for binary-compatible changes 00193 }; 00194 } 00195 } 00196 00197 #endif // EQUTIL_OBJECTMANAGER_H 00198
1.3.1-git by
1.8.0