BsIndexBuffer.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. /**
  22. * @brief Returns the type of indices stored.
  23. */
  24. IndexType getType() const { return mIndexType; }
  25. /**
  26. * @brief Returns the number of indices this buffer can hold.
  27. */
  28. UINT32 getNumIndices() const { return mNumIndexes; }
  29. /**
  30. * @brief Returns the size of a single index in bytes.
  31. */
  32. UINT32 getIndexSize() const { return mIndexSize; }
  33. protected:
  34. friend class IndexBuffer;
  35. friend class IndexBufferCore;
  36. IndexType mIndexType;
  37. UINT32 mNumIndexes;
  38. UINT32 mIndexSize;
  39. };
  40. /**
  41. * @brief Core thread specific implementation of an index buffer.
  42. *
  43. * @see IndexBuffer
  44. */
  45. class BS_CORE_EXPORT IndexBufferCore : public CoreObjectCore, public HardwareBuffer
  46. {
  47. public:
  48. IndexBufferCore(GpuBufferUsage usage, bool useSystemMemory, const IndexBufferProperties& properties);
  49. virtual ~IndexBufferCore() { }
  50. /**
  51. * @brief Returns information about the index buffer.
  52. */
  53. const IndexBufferProperties& getProperties() const { return mProperties; }
  54. protected:
  55. IndexBufferProperties mProperties;
  56. };
  57. /**
  58. * @brief Hardware buffer that hold indices that reference vertices in a vertex buffer.
  59. */
  60. class BS_CORE_EXPORT IndexBuffer : public CoreObject
  61. {
  62. public:
  63. virtual ~IndexBuffer() { }
  64. /**
  65. * @brief Returns information about the index buffer.
  66. */
  67. const IndexBufferProperties& getProperties() const { return mProperties; }
  68. /**
  69. * @brief Retrieves a core implementation of an index buffer
  70. * usable only from the core thread.
  71. *
  72. * @note Core thread only.
  73. */
  74. SPtr<IndexBufferCore> getCore() const;
  75. /**
  76. * @copydoc HardwareBufferManager::createIndexBuffer
  77. */
  78. static IndexBufferPtr create(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
  79. protected:
  80. IndexBuffer(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage, bool useSystemMemory);
  81. IndexBufferProperties mProperties;
  82. GpuBufferUsage mUsage;
  83. bool mUseSystemMemory;
  84. };
  85. }