BsVertexData.h 1.6 KB

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