1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#pragma once
4
5#include "BsCorePrerequisites.h"
6#include "RenderAPI/BsVertexDeclaration.h"
7#include "RenderAPI/BsVertexBuffer.h"
8
9namespace bs { namespace ct
10{
11 /** @addtogroup RenderAPI
12 * @{
13 */
14
15 /**
16 * Container class consisting of a set of vertex buffers and their declaration.
17 *
18 * @note Used just for more easily passing around vertex information.
19 */
20 class BS_CORE_EXPORT VertexData
21 {
22 public:
23 VertexData() = default;
24 ~VertexData() = default;
25
26 /** Assigns a new vertex buffer to the specified index. */
27 void setBuffer(UINT32 index, SPtr<VertexBuffer> buffer);
28
29 /** Retrieves a vertex buffer from the specified index. */
30 SPtr<VertexBuffer> getBuffer(UINT32 index) const;
31
32 /** Returns a list of all bound vertex buffers. */
33 const UnorderedMap<UINT32, SPtr<VertexBuffer>>& getBuffers() const { return mVertexBuffers; }
34
35 /** Checks if there is a buffer at the specified index. */
36 bool isBufferBound(UINT32 index) const;
37
38 /** Gets total number of bound buffers. */
39 UINT32 getBufferCount() const { return (UINT32)mVertexBuffers.size(); }
40
41 /** Returns the maximum index of all bound buffers. */
42 UINT32 getMaxBufferIndex() const { return mMaxBufferIdx; }
43
44 /** Declaration used for the contained vertex buffers. */
45 SPtr<VertexDeclaration> vertexDeclaration;
46
47 /** Number of vertices to use. */
48 UINT32 vertexCount = 0;
49
50 private:
51 void recalculateMaxIndex();
52
53 UnorderedMap<UINT32, SPtr<VertexBuffer>> mVertexBuffers;
54 UINT32 mMaxBufferIdx = 0;
55 };
56
57 /** @} */
58}}