/* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Author: * Sinbad, Baxissimo, DWORD, TheBren (OGRE Wiki) * Co-authors: * ... * */ #ifndef _DynamicRenderable_H__ #define _DynamicRenderable_H__ #include "tools/ToolsPrereqs.h" #include namespace Ogre { /// Abstract base class providing mechanisms for dynamically growing hardware buffers. class _ToolsExport DynamicRenderable : public SimpleRenderable { public: /// Constructor DynamicRenderable(); /// Virtual destructor virtual ~DynamicRenderable(); /** @brief Initializes the dynamic renderable. @remarks This function should only be called once. It initializes the render operation, and calls the abstract function createVertexDeclaration(). @param operationType The type of render operation to perform. @param useIndices Specifies whether to use indices to determine the vertices to use as input. */ void initialize(RenderOperation::OperationType operationType, bool useIndices); /// Implementation of SimpleRenderable virtual Real getBoundingRadius(void) const override; /// Implementation of SimpleRenderable virtual Real getSquaredViewDepth(const Camera* cam) const override; protected: /// Maximum capacity of the currently allocated vertex buffer. size_t mVertexBufferCapacity; /// Maximum capacity of the currently allocated index buffer. size_t mIndexBufferCapacity; /** @brief Creates the vertex declaration. @remarks Override and set mRenderOp.vertexData->vertexDeclaration here. mRenderOp.vertexData will be created for you before this method is called. */ virtual void createVertexDeclaration() = 0; /** @brief Prepares the hardware buffers for the requested vertex and index counts. @remarks This function must be called before locking the buffers in fillHardwareBuffers(). It guarantees that the hardware buffers are large enough to hold at least the requested number of vertices and indices (if using indices). The buffers are possibly reallocated to achieve this. @par The vertex and index count in the render operation are set to the values of vertexCount and indexCount respectively. @param vertexCount The number of vertices the buffer must hold. @param indexCount The number of indices the buffer must hold. This parameter is ignored if not using indices. */ void prepareHardwareBuffers(size_t vertexCount, size_t indexCount); /** @brief Fills the hardware vertex and index buffers with data. @remarks This function must call prepareHardwareBuffers() before locking the buffers to ensure the they are large enough for the data to be written. Afterwards the vertex and index buffers (if using indices) can be locked, and data can be written to them. */ virtual void fillHardwareBuffers() = 0; }; } #endif /* _DynamicRenderable_H__ */