BsVertexBuffer.h 2.2 KB

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