BsVertexBuffer.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsHardwareBuffer.h"
  4. #include "BsCoreObject.h"
  5. #include "BsColor.h"
  6. namespace BansheeEngine
  7. {
  8. /**
  9. * @brief Contains information about a vertex buffer buffer.
  10. */
  11. class BS_CORE_EXPORT VertexBufferProperties
  12. {
  13. public:
  14. VertexBufferProperties(UINT32 numVertices, UINT32 vertexSize);
  15. /**
  16. * @brief Gets the size in bytes of a single vertex in this buffer.
  17. */
  18. UINT32 getVertexSize() const { return mVertexSize; }
  19. /**
  20. * @brief Get the number of vertices in this buffer.
  21. */
  22. UINT32 getNumVertices() const { return mNumVertices; }
  23. protected:
  24. friend class VertexBuffer;
  25. friend class VertexBufferCore;
  26. UINT32 mNumVertices;
  27. UINT32 mVertexSize;
  28. };
  29. /**
  30. * @brief Core thread specific implementation of a vertex buffer.
  31. *
  32. * @see VertexBuffer
  33. */
  34. class BS_CORE_EXPORT VertexBufferCore : public CoreObjectCore, public HardwareBuffer
  35. {
  36. public:
  37. VertexBufferCore(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool streamOut);
  38. virtual ~VertexBufferCore() { }
  39. /**
  40. * @brief Returns information about the vertex buffer.
  41. */
  42. const VertexBufferProperties& getProperties() const { return mProperties; }
  43. protected:
  44. VertexBufferProperties mProperties;
  45. };
  46. /**
  47. * @brief Specialization of a hardware buffer used for holding vertex data.
  48. */
  49. class BS_CORE_EXPORT VertexBuffer : public CoreObject
  50. {
  51. public:
  52. virtual ~VertexBuffer() { }
  53. /**
  54. * @brief Retrieves a core implementation of a vertex buffer
  55. * usable only from the core thread.
  56. *
  57. * @note Core thread only.
  58. */
  59. SPtr<VertexBufferCore> getCore() const;
  60. /**
  61. * @copydoc HardwareBufferManager::createVertexBuffer
  62. */
  63. static VertexBufferPtr create(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
  64. static const int MAX_SEMANTIC_IDX = 8;
  65. protected:
  66. friend class HardwareBufferManager;
  67. VertexBuffer(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool streamOut = false);
  68. /**
  69. * @copydoc CoreObject::createCore
  70. */
  71. virtual SPtr<CoreObjectCore> createCore() const;
  72. protected:
  73. VertexBufferProperties mProperties;
  74. GpuBufferUsage mUsage;
  75. bool mStreamOut;
  76. };
  77. }