Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/tools/DynamicRenderable.h @ 9789

Last change on this file since 9789 was 5781, checked in by rgrieder, 15 years ago

Reverted trunk again. We might want to find a way to delete these revisions again (x3n's changes are still available as diff in the commit mails).

  • Property svn:eol-style set to native
File size: 4.1 KB
Line 
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 "tools/ToolsPrereqs.h"
33
34#include <OgreSimpleRenderable.h>
35
36namespace Ogre
37{
38    /// Abstract base class providing mechanisms for dynamically growing hardware buffers.
39    class _ToolsExport DynamicRenderable : public SimpleRenderable
40    {
41    public:
42        /// Constructor
43        DynamicRenderable();
44        /// Virtual destructor
45        virtual ~DynamicRenderable();
46
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);
61
62        /// Implementation of SimpleRenderable
63        virtual Real getBoundingRadius(void) const;
64        /// Implementation of SimpleRenderable
65        virtual Real getSquaredViewDepth(const Camera* cam) const;
66
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;
72
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;
82
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);
102
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    };
114}
115
116#endif /* _DynamicRenderable_H__ */
Note: See TracBrowser for help on using the repository browser.