2
0

BsVertexBuffer.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. /** @cond INTERNAL */
  28. /** Core thread specific implementation of a VertexBuffer. */
  29. class BS_CORE_EXPORT VertexBufferCore : public CoreObjectCore, public HardwareBuffer
  30. {
  31. public:
  32. VertexBufferCore(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool streamOut);
  33. virtual ~VertexBufferCore() { }
  34. /** Returns information about the vertex buffer. */
  35. const VertexBufferProperties& getProperties() const { return mProperties; }
  36. protected:
  37. VertexBufferProperties mProperties;
  38. };
  39. /** @endcond */
  40. /** Specialization of a hardware buffer used for holding vertex data. */
  41. class BS_CORE_EXPORT VertexBuffer : public CoreObject
  42. {
  43. public:
  44. virtual ~VertexBuffer() { }
  45. /**
  46. * Retrieves a core implementation of a vertex buffer usable only from the core thread.
  47. *
  48. * @note Core thread only.
  49. */
  50. SPtr<VertexBufferCore> getCore() const;
  51. /** @copydoc HardwareBufferManager::createVertexBuffer */
  52. static VertexBufferPtr create(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
  53. static const int MAX_SEMANTIC_IDX = 8;
  54. protected:
  55. friend class HardwareBufferManager;
  56. VertexBuffer(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool streamOut = false);
  57. /** @copydoc CoreObject::createCore */
  58. virtual SPtr<CoreObjectCore> createCore() const;
  59. protected:
  60. VertexBufferProperties mProperties;
  61. GpuBufferUsage mUsage;
  62. bool mStreamOut;
  63. };
  64. /** @} */
  65. }