2
0

BsIndexBuffer.h 2.7 KB

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