OgreVertexIndexData.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2006 Torus Knot Software Ltd
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 
00024 You may alternatively use this source under the terms of a specific version of
00025 the OGRE Unrestricted License provided you have obtained such a license from
00026 Torus Knot Software Ltd.
00027 -----------------------------------------------------------------------------
00028 */
00029 #ifndef __VertexIndexData_H__
00030 #define __VertexIndexData_H__
00031 
00032 #include "OgrePrerequisites.h"
00033 #include "OgreHardwareVertexBuffer.h"
00034 #include "OgreHardwareIndexBuffer.h"
00035 
00036 namespace Ogre {
00037     
00039     typedef std::vector<HardwareBuffer::Usage> BufferUsageList;
00040 
00041 
00043     class _OgreExport VertexData : public VertexDataAlloc
00044     {
00045     private:
00047         VertexData(const VertexData& rhs); /* do nothing, should not use */
00049         VertexData& operator=(const VertexData& rhs); /* do not use */
00050     public:
00051         VertexData();
00052         ~VertexData();
00053 
00057         VertexDeclaration* vertexDeclaration;
00061         VertexBufferBinding* vertexBufferBinding;
00063         size_t vertexStart;
00065         size_t vertexCount;
00066 
00067 
00069         struct HardwareAnimationData
00070         {
00071             const VertexElement* targetVertexElement;
00072             Real parametric;
00073         };
00074         typedef std::vector<HardwareAnimationData> HardwareAnimationDataList;
00076         HardwareAnimationDataList hwAnimationDataList;
00078         size_t hwAnimDataItemsUsed;
00079         
00083         VertexData* clone(bool copyData = true) const;
00084 
00104         void prepareForShadowVolume(void);
00105 
00119         HardwareVertexBufferSharedPtr hardwareShadowVolWBuffer;
00120 
00121 
00138         void reorganiseBuffers(VertexDeclaration* newDeclaration, const BufferUsageList& bufferUsage);
00139 
00155         void reorganiseBuffers(VertexDeclaration* newDeclaration);
00156 
00166         void closeGapsInBindings(void);
00167 
00176         void removeUnusedBuffers(void);
00177 
00185         void convertPackedColour(VertexElementType srcType, VertexElementType destType);
00186 
00187 
00201         void allocateHardwareAnimationElements(ushort count);
00202 
00203 
00204 
00205     };
00206 
00208     class _OgreExport IndexData : public IndexDataAlloc
00209     {
00210     protected:
00212         IndexData(const IndexData& rhs); /* do nothing, should not use */
00214         IndexData& operator=(const IndexData& rhs); /* do not use */
00215     public:
00216         IndexData();
00217         ~IndexData();
00219         HardwareIndexBufferSharedPtr indexBuffer;
00220 
00222         size_t indexStart;
00223 
00225         size_t indexCount;
00226 
00230         IndexData* clone(bool copyData = true) const;
00231 
00240         void optimiseVertexCacheTriList(void);
00241     
00242     };
00243 
00249     class _OgreExport VertexCacheProfiler : public BufferAlloc
00250     {
00251         public:
00252             enum CacheType {
00253                 FIFO, LRU
00254             };
00255 
00256             VertexCacheProfiler(unsigned int cachesize = 16, CacheType cachetype = FIFO )
00257                 : size ( cachesize ), type ( cachetype ), tail (0), buffersize (0), hit (0), miss (0)
00258             {
00259                 cache = OGRE_ALLOC_T(uint32, size, MEMCATEGORY_GEOMETRY);
00260             };
00261 
00262             ~VertexCacheProfiler()
00263             {
00264                 OGRE_FREE(cache, MEMCATEGORY_GEOMETRY);
00265             }
00266 
00267             void profile(const HardwareIndexBufferSharedPtr& indexBuffer);
00268             void reset() { hit = 0; miss = 0; tail = 0; buffersize = 0; };
00269             void flush() { tail = 0; buffersize = 0; };
00270 
00271             unsigned int getHits() { return hit; };
00272             unsigned int getMisses() { return miss; };
00273             unsigned int getSize() { return size; };
00274         private:
00275             unsigned int size;
00276             uint32 *cache;
00277             CacheType type;
00278 
00279             unsigned int tail, buffersize;
00280             unsigned int hit, miss;
00281 
00282             bool inCache(unsigned int index);
00283     };
00284 }
00285 #endif
00286 

Copyright © 2008 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 27 22:02:26 2009