Changeset 3130 for code/branches/pch/src/orxonox/tools/DynamicRenderable.h
- Timestamp:
- Jun 9, 2009, 7:51:00 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pch/src/orxonox/tools/DynamicRenderable.h
r3089 r3130 1 #ifndef DYNAMIC_RENDERABLE_H 2 #define DYNAMIC_RENDERABLE_H 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 22 * Author: 23 * Sinbad, Baxissimo, DWORD, TheBren (OGRE Wiki) 24 * Co-authors: 25 * ... 26 * 27 */ 28 29 #ifndef _DynamicRenderable_H__ 30 #define _DynamicRenderable_H__ 31 32 #include "OrxonoxPrereqs.h" 3 33 4 34 #include <OgreSimpleRenderable.h> 5 35 6 namespace orxonox36 namespace Ogre 7 37 { 8 /// Abstract base class providing mechanisms for dynamically growing hardware buffers.9 class DynamicRenderable : public Ogre::SimpleRenderable10 {11 public:12 /// Constructor13 DynamicRenderable();14 /// Virtual destructor15 virtual ~DynamicRenderable();38 /// Abstract base class providing mechanisms for dynamically growing hardware buffers. 39 class DynamicRenderable : public SimpleRenderable 40 { 41 public: 42 /// Constructor 43 DynamicRenderable(); 44 /// Virtual destructor 45 virtual ~DynamicRenderable(); 16 46 17 /** Initializes the dynamic renderable. 18 @remarks 19 This function should only be called once. It initializes the 20 render operation, and calls the abstract function 21 createVertexDeclaration(). 22 @param operationType The type of render operation to perform. 23 @param useIndices Specifies whether to use indices to determine the 24 vertices to use as input. */ 25 void initialize(Ogre::RenderOperation::OperationType operationType, 26 bool useIndices); 47 /** 48 @brief 49 Initializes the dynamic renderable. 50 @remarks 51 This function should only be called once. It initializes the 52 render operation, and calls the abstract function 53 createVertexDeclaration(). 54 @param operationType 55 The type of render operation to perform. 56 @param useIndices 57 Specifies whether to use indices to determine the vertices to use as input. 58 */ 59 void initialize(RenderOperation::OperationType operationType, 60 bool useIndices); 27 61 28 /// Implementation of Ogre::SimpleRenderable29 virtual Ogre::Real getBoundingRadius(void) const;30 /// Implementation of Ogre::SimpleRenderable31 virtual Ogre::Real getSquaredViewDepth(const Ogre::Camera* cam) const;62 /// Implementation of SimpleRenderable 63 virtual Real getBoundingRadius(void) const; 64 /// Implementation of SimpleRenderable 65 virtual Real getSquaredViewDepth(const Camera* cam) const; 32 66 33 protected:34 /// Maximum capacity of the currently allocated vertex buffer.35 size_t mVertexBufferCapacity;36 /// Maximum capacity of the currently allocated index buffer.37 size_t mIndexBufferCapacity;67 protected: 68 /// Maximum capacity of the currently allocated vertex buffer. 69 size_t mVertexBufferCapacity; 70 /// Maximum capacity of the currently allocated index buffer. 71 size_t mIndexBufferCapacity; 38 72 39 /** Creates the vertex declaration. 40 @remarks 41 Override and set mRenderOp.vertexData->vertexDeclaration here. 42 mRenderOp.vertexData will be created for you before this method 43 is called. */ 44 virtual void createVertexDeclaration() = 0; 73 /** 74 @brief 75 Creates the vertex declaration. 76 @remarks 77 Override and set mRenderOp.vertexData->vertexDeclaration here. 78 mRenderOp.vertexData will be created for you before this method 79 is called. 80 */ 81 virtual void createVertexDeclaration() = 0; 45 82 46 /** Prepares the hardware buffers for the requested vertex and index counts. 47 @remarks 48 This function must be called before locking the buffers in 49 fillHardwareBuffers(). It guarantees that the hardware buffers 50 are large enough to hold at least the requested number of 51 vertices and indices (if using indices). The buffers are 52 possibly reallocated to achieve this. 53 @par 54 The vertex and index count in the render operation are set to 55 the values of vertexCount and indexCount respectively. 56 @param vertexCount The number of vertices the buffer must hold. 83 /** 84 @brief 85 Prepares the hardware buffers for the requested vertex and index counts. 86 @remarks 87 This function must be called before locking the buffers in 88 fillHardwareBuffers(). It guarantees that the hardware buffers 89 are large enough to hold at least the requested number of 90 vertices and indices (if using indices). The buffers are 91 possibly reallocated to achieve this. 92 @par 93 The vertex and index count in the render operation are set to 94 the values of vertexCount and indexCount respectively. 95 @param vertexCount 96 The number of vertices the buffer must hold. 97 @param indexCount 98 The number of indices the buffer must hold. This 99 parameter is ignored if not using indices. 100 */ 101 void prepareHardwareBuffers(size_t vertexCount, size_t indexCount); 57 102 58 @param indexCount The number of indices the buffer must hold. This 59 parameter is ignored if not using indices. */ 60 void prepareHardwareBuffers(size_t vertexCount, size_t indexCount); 61 62 /** Fills the hardware vertex and index buffers with data. 63 @remarks 64 This function must call prepareHardwareBuffers() before locking 65 the buffers to ensure the they are large enough for the data to 66 be written. Afterwards the vertex and index buffers (if using 67 indices) can be locked, and data can be written to them. */ 68 virtual void fillHardwareBuffers() = 0; 69 }; 103 /** 104 @brief 105 Fills the hardware vertex and index buffers with data. 106 @remarks 107 This function must call prepareHardwareBuffers() before locking 108 the buffers to ensure the they are large enough for the data to 109 be written. Afterwards the vertex and index buffers (if using 110 indices) can be locked, and data can be written to them. 111 */ 112 virtual void fillHardwareBuffers() = 0; 113 }; 70 114 } 71 115 72 #endif / / DYNAMIC_RENDERABLE_H116 #endif /* _DynamicRenderable_H__ */
Note: See TracChangeset
for help on using the changeset viewer.