Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/tools/DynamicRenderable.h @ 3089

Last change on this file since 3089 was 3089, checked in by landauf, 15 years ago

merged map branch back to trunk

  • Property svn:eol-style set to native
File size: 2.7 KB
Line 
1#ifndef DYNAMIC_RENDERABLE_H
2#define DYNAMIC_RENDERABLE_H
3
4#include <OgreSimpleRenderable.h>
5
6namespace orxonox
7{
8/// Abstract base class providing mechanisms for dynamically growing hardware buffers.
9class DynamicRenderable : public Ogre::SimpleRenderable
10{
11public:
12  /// Constructor
13  DynamicRenderable();
14  /// Virtual destructor
15  virtual ~DynamicRenderable();
16
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);
27
28  /// Implementation of Ogre::SimpleRenderable
29  virtual Ogre::Real getBoundingRadius(void) const;
30  /// Implementation of Ogre::SimpleRenderable
31  virtual Ogre::Real getSquaredViewDepth(const Ogre::Camera* cam) const;
32
33protected:
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;
38
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;
45
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.
57
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};
70}
71
72#endif // DYNAMIC_RENDERABLE_H
Note: See TracBrowser for help on using the repository browser.