BsIndexBuffer.h 2.4 KB

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