BsVertexBuffer.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 VertexBufferPtr create(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
  40. static const int MAX_SEMANTIC_IDX = 8;
  41. protected:
  42. friend class HardwareBufferManager;
  43. VertexBuffer(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool streamOut = false);
  44. /** @copydoc CoreObject::createCore */
  45. virtual SPtr<CoreObjectCore> createCore() const;
  46. protected:
  47. VertexBufferProperties mProperties;
  48. GpuBufferUsage mUsage;
  49. bool mStreamOut;
  50. };
  51. /** @} */
  52. /** @addtogroup RenderAPI-Internal
  53. * @{
  54. */
  55. /** Core thread specific implementation of a VertexBuffer. */
  56. class BS_CORE_EXPORT VertexBufferCore : public CoreObjectCore, public HardwareBuffer
  57. {
  58. public:
  59. VertexBufferCore(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool streamOut);
  60. virtual ~VertexBufferCore() { }
  61. /** Returns information about the vertex buffer. */
  62. const VertexBufferProperties& getProperties() const { return mProperties; }
  63. protected:
  64. VertexBufferProperties mProperties;
  65. };
  66. /** @} */
  67. }