BsVertexData.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. #include "RenderAPI/BsVertexDeclaration.h"
  6. #include "RenderAPI/BsVertexBuffer.h"
  7. namespace bs { namespace ct
  8. {
  9. /** @addtogroup RenderAPI
  10. * @{
  11. */
  12. /**
  13. * Container class consisting of a set of vertex buffers and their declaration.
  14. *
  15. * @note Used just for more easily passing around vertex information.
  16. */
  17. class BS_CORE_EXPORT VertexData
  18. {
  19. public:
  20. VertexData();
  21. ~VertexData();
  22. /** Assigns a new vertex buffer to the specified index. */
  23. void setBuffer(UINT32 index, SPtr<VertexBuffer> buffer);
  24. /** Retrieves a vertex buffer from the specified index. */
  25. SPtr<VertexBuffer> getBuffer(UINT32 index) const;
  26. /** Returns a list of all bound vertex buffers. */
  27. const UnorderedMap<UINT32, SPtr<VertexBuffer>>& getBuffers() const { return mVertexBuffers; }
  28. /** Checks if there is a buffer at the specified index. */
  29. bool isBufferBound(UINT32 index) const;
  30. /** Gets total number of bound buffers. */
  31. UINT32 getBufferCount() const { return (UINT32)mVertexBuffers.size(); }
  32. /** Returns the maximum index of all bound buffers. */
  33. UINT32 getMaxBufferIndex() const { return mMaxBufferIdx; }
  34. /** Declaration used for the contained vertex buffers. */
  35. SPtr<VertexDeclaration> vertexDeclaration;
  36. /** Number of vertices to use. */
  37. UINT32 vertexCount;
  38. private:
  39. void recalculateMaxIndex();
  40. UnorderedMap<UINT32, SPtr<VertexBuffer>> mVertexBuffers;
  41. UINT32 mMaxBufferIdx = 0;
  42. };
  43. /** @} */
  44. }}