BsVertexBuffer.h 2.7 KB

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