BsVertexBuffer.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. /**
  15. * @brief Gets the size in bytes of a single vertex in this buffer.
  16. */
  17. UINT32 getVertexSize() const { return mVertexSize; }
  18. /**
  19. * @brief Get the number of vertices in this buffer.
  20. */
  21. UINT32 getNumVertices() const { return mNumVertices; }
  22. protected:
  23. friend class VertexBuffer;
  24. friend class VertexBufferCore;
  25. UINT32 mNumVertices;
  26. UINT32 mVertexSize;
  27. };
  28. /**
  29. * @brief Core thread specific implementation of a vertex buffer.
  30. *
  31. * @see VertexBuffer
  32. */
  33. class BS_CORE_EXPORT VertexBufferCore : public CoreObjectCore, public HardwareBuffer
  34. {
  35. public:
  36. VertexBufferCore(GpuBufferUsage usage, bool useSystemMemory, const VertexBufferProperties& properties);
  37. virtual ~VertexBufferCore() { }
  38. /**
  39. * @brief Returns information about the vertex buffer.
  40. */
  41. const VertexBufferProperties& getProperties() const { return mProperties; }
  42. protected:
  43. VertexBufferProperties mProperties;
  44. };
  45. /**
  46. * @brief Specialization of a hardware buffer used for holding vertex data.
  47. */
  48. class BS_CORE_EXPORT VertexBuffer : public CoreObject
  49. {
  50. public:
  51. virtual ~VertexBuffer() { }
  52. /**
  53. * @brief Retrieves a core implementation of a vertex buffer
  54. * usable only from the core thread.
  55. *
  56. * @note Core thread only.
  57. */
  58. SPtr<VertexBufferCore> getCore() const;
  59. /**
  60. * @copydoc HardwareBufferManager::createVertexBuffer
  61. */
  62. static VertexBufferPtr create(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
  63. static const int MAX_SEMANTIC_IDX = 8;
  64. protected:
  65. VertexBuffer(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool useSystemMemory);
  66. protected:
  67. VertexBufferProperties mProperties;
  68. GpuBufferUsage mUsage;
  69. bool mUseSystemMemory;
  70. };
  71. }