| VRS - The Virtual Rendering System |
| version 3.3 |
00001 /****************************************************************************** 00002 * VRS - The Virtual Rendering System 00003 * Copyright (C) 2003 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: bufferobjectgl.h 6689 2009-04-15 15:01:26Z Matthias_Trapp $ 00019 // $Date: 2009-04-15 17:01:26 +0200 (Wed, 15 Apr 2009) $ 00020 // $Revision: 6689 $ 00021 // $State$ 00022 // $Author: Matthias_Trapp $ 00023 // 00024 // $Log$ 00025 // Revision 1.18 2006/05/16 14:11:09 baumann 00026 // added new method changeType() 00027 // 00028 // Revision 1.17 2006/05/16 13:30:58 baumann 00029 // added support for EXT_pbo 00030 // 00031 // Revision 1.16 2005/10/14 10:14:38 baumann 00032 // enabled VBOs per default 00033 // 00034 // Revision 1.15 2005/01/03 01:43:09 klimetschek 00035 // - modified win32 project layout, splitted vrs.vcproj into vrs_container, vrs_core, vrs_sg, vrs_image, vrs_opengl and vrs_io 00036 // - removed vrs.vcproj 00037 // minor things: 00038 // - added all glutexamples to vrs4glut.sln 00039 // - fixed some problems in glutexamples 00040 // - removed all project references from all VS projects (using solution wide project dependencies instead) 00041 // 00042 // Revision 1.14 2004/12/03 16:26:40 buchholz 00043 // dataType() method added 00044 // 00045 // Revision 1.13 2004/11/03 14:45:06 saar 00046 // Class comment changed (Doxygen style) 00047 // 00048 // Revision 1.12 2004/09/19 15:30:32 baumann 00049 // parameter offset added to methods boundAddress() 00050 // 00051 // Revision 1.11 2004/03/12 16:28:40 baumann 00052 // macros VRS_NAMESPACE_BEGIN/_END expanded and removed 00053 // 00054 // Revision 1.10 2004/01/19 11:43:58 baumann 00055 // serialization mechanism improved 00056 // 00057 // Revision 1.9 2004/01/19 07:28:02 baumann 00058 // serialization mechanism improved 00059 // 00060 // Revision 1.8 2003/12/09 14:56:54 buchholz 00061 // serialization for self-contained buffer-objects added 00062 // 00063 // Revision 1.7 2003/11/24 10:38:18 baumann 00064 // - general code cleanup 00065 // - new method replace() added 00066 // 00067 // Revision 1.6 2003/06/03 09:04:46 baumann 00068 // new static methods getMinimumVBOSize()/setMinimumVBOSize()/ 00069 // isVBOEnabled()/enableVBO() added to BufferObjectGL; defaults are: 00070 // minimum VBO size = 1024 bytes; VBO disabled 00071 // 00072 // Revision 1.5 2003/05/26 17:02:10 baumann 00073 // BufferObjectGL tries to transfer the data to the graphics memory 00074 // for a second time (during the bind()-call) if no EngineGL was 00075 // specified during the construction of the BufferObjectGL object 00076 // 00077 // Revision 1.4 2003/04/13 15:33:30 baumann 00078 // typo in comment fixed 00079 // 00080 // Revision 1.3 2003/04/04 08:02:09 baumann 00081 // comments added 00082 // 00083 // Revision 1.2 2003/04/02 06:55:50 baumann 00084 // interface improved 00085 // 00086 // Revision 1.1 2003/03/31 17:00:14 baumann 00087 // initial version of BufferObjectGL and VertexAttributeBufferObjectGL 00088 // 00089 00090 #ifndef VRS_OPENGL_BUFFEROBJECTGL_H 00091 #define VRS_OPENGL_BUFFEROBJECTGL_H 00092 00093 #include <vrs/sharedobj.h> 00094 00095 namespace VRS { 00096 00097 class EngineGL; 00098 00102 class VRS_CORE_API BufferObjectGL : public SharedObj { 00103 00104 public: 00105 enum DataType { 00106 UNCLASSIFIED, VERTEX_DATA, VERTEX_INDICES, PIXEL_PACK, PIXEL_UNPACK, UNIFORM_DATA, TEXTURE_BUFFER_DATA 00107 }; 00108 VRS_SERIALIZABLE_CLASS_ENUM(DataType); 00117 enum UsagePattern { 00118 STREAM_DRAW, STATIC_DRAW, DYNAMIC_DRAW, 00119 STREAM_READ, STATIC_READ, DYNAMIC_READ, 00120 STREAM_COPY, STATIC_COPY, DYNAMIC_COPY 00121 }; 00122 VRS_SERIALIZABLE_CLASS_ENUM(UsagePattern); 00131 enum MapAccess { 00132 READ_ONLY, WRITE_ONLY, READ_WRITE 00133 }; 00139 BufferObjectGL( 00140 EngineGL* engine, 00141 unsigned int bytes, 00142 const void* pointer, 00143 DataType type, 00144 UsagePattern usagePattern 00145 ); 00153 BufferObjectGL( 00154 unsigned int bytes, 00155 const void* pointer, 00156 SharedObj* owner = NULL 00157 ); 00165 virtual ~BufferObjectGL(); 00167 00168 unsigned int bytes() const; 00170 00171 void* mapPointer(MapAccess access); 00172 const void* mapPointer(MapAccess access) const; // can only be used with READ_ONLY! 00173 bool unmapPointer() const; 00174 bool pointerIsMapped() const; 00187 void update( 00188 unsigned int bytes, 00189 const void* pointer, 00190 unsigned int byteOffset = 0 00191 ); 00196 void replace( 00197 unsigned int bytes, 00198 const void* pointer 00199 ); 00206 void bind(EngineGL* engine) const; 00207 void* boundAddress(unsigned int offset = 0); // for e.g. glVertexPointer(..., buffer->boundAddress()); 00208 const void* boundAddress(unsigned int offset = 0) const; // for e.g. glVertexPointer(..., buffer->boundAddress()); 00209 void unbind(EngineGL* engine) const; 00219 void changeType(DataType newDataType); 00227 static unsigned int getMinimumVBOSize(); 00228 static void setMimimumVBOSize(unsigned int vboSize = 0); 00233 static bool isVBOEnabled(); 00234 static void enableVBO(bool yesNo = true); 00240 00241 DataType dataType() const; 00242 00243 VRS_TYPEINFO(BufferObjectGL, SharedObj); 00244 VRS_SERIALIZABLE(BufferObjectGL); 00245 00246 class Impl; 00247 00248 protected: 00249 BufferObjectGL(); // for serialization only 00250 00251 private: 00252 // disable copy constructor and assignment operator 00253 BufferObjectGL(const BufferObjectGL&); 00254 BufferObjectGL& operator=(const BufferObjectGL&); 00255 00256 UINT bytes_; 00257 DataType type_; 00258 UsagePattern usage_; 00259 00260 mutable bool tryToOptimize_; 00261 mutable Impl* impl_; 00262 bool serializable_; 00263 }; // class BufferObjectGL 00264 00265 } // namespace VRS 00266 00267 #endif // VRS_OPENGL_BUFFEROBJECTGL_H