BsIndexBuffer.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsHardwareBuffer.h"
  4. #include "BsCoreObject.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief Type of the indices used, used for determining size.
  9. */
  10. enum IndexType
  11. {
  12. IT_16BIT,
  13. IT_32BIT
  14. };
  15. /**
  16. * @brief Contains information about an index buffer.
  17. */
  18. class BS_CORE_EXPORT IndexBufferProperties
  19. {
  20. public:
  21. IndexBufferProperties(IndexType idxType, UINT32 numIndexes);
  22. /**
  23. * @brief Returns the type of indices stored.
  24. */
  25. IndexType getType() const { return mIndexType; }
  26. /**
  27. * @brief Returns the number of indices this buffer can hold.
  28. */
  29. UINT32 getNumIndices() const { return mNumIndexes; }
  30. /**
  31. * @brief Returns the size of a single index in bytes.
  32. */
  33. UINT32 getIndexSize() const { return mIndexSize; }
  34. protected:
  35. friend class IndexBuffer;
  36. friend class IndexBufferCore;
  37. IndexType mIndexType;
  38. UINT32 mNumIndexes;
  39. UINT32 mIndexSize;
  40. };
  41. /**
  42. * @brief Core thread specific implementation of an index buffer.
  43. *
  44. * @see IndexBuffer
  45. */
  46. class BS_CORE_EXPORT IndexBufferCore : public CoreObjectCore, public HardwareBuffer
  47. {
  48. public:
  49. IndexBufferCore(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage);
  50. virtual ~IndexBufferCore() { }
  51. /**
  52. * @brief Returns information about the index buffer.
  53. */
  54. const IndexBufferProperties& getProperties() const { return mProperties; }
  55. protected:
  56. IndexBufferProperties mProperties;
  57. };
  58. /**
  59. * @brief Hardware buffer that hold indices that reference vertices in a vertex buffer.
  60. */
  61. class BS_CORE_EXPORT IndexBuffer : public CoreObject
  62. {
  63. public:
  64. virtual ~IndexBuffer() { }
  65. /**
  66. * @brief Returns information about the index buffer.
  67. */
  68. const IndexBufferProperties& getProperties() const { return mProperties; }
  69. /**
  70. * @brief Retrieves a core implementation of an index buffer
  71. * usable only from the core thread.
  72. *
  73. * @note Core thread only.
  74. */
  75. SPtr<IndexBufferCore> getCore() const;
  76. /**
  77. * @copydoc HardwareBufferManager::createIndexBuffer
  78. */
  79. static IndexBufferPtr create(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
  80. protected:
  81. friend class HardwareBufferManager;
  82. IndexBuffer(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage);
  83. /**
  84. * @copydoc CoreObject::createCore
  85. */
  86. virtual SPtr<CoreObjectCore> createCore() const;
  87. IndexBufferProperties mProperties;
  88. GpuBufferUsage mUsage;
  89. };
  90. }