BsVertexData.h 1.5 KB

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