BsVertexData.h 1.9 KB

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