2
0

BsIndexBuffer.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. /** @cond INTERNAL */
  37. /** Core thread specific implementation of an IndexBuffer. */
  38. class BS_CORE_EXPORT IndexBufferCore : public CoreObjectCore, public HardwareBuffer
  39. {
  40. public:
  41. IndexBufferCore(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage);
  42. virtual ~IndexBufferCore() { }
  43. /** Returns information about the index buffer. */
  44. const IndexBufferProperties& getProperties() const { return mProperties; }
  45. protected:
  46. IndexBufferProperties mProperties;
  47. };
  48. /** @endcond */
  49. /** Hardware buffer that hold indices that reference vertices in a vertex buffer. */
  50. class BS_CORE_EXPORT IndexBuffer : public CoreObject
  51. {
  52. public:
  53. virtual ~IndexBuffer() { }
  54. /** Returns information about the index buffer. */
  55. const IndexBufferProperties& getProperties() const { return mProperties; }
  56. /**
  57. * Retrieves a core implementation of an index buffer usable only from the core thread.
  58. *
  59. * @note Core thread only.
  60. */
  61. SPtr<IndexBufferCore> getCore() const;
  62. /** @copydoc HardwareBufferManager::createIndexBuffer */
  63. static IndexBufferPtr create(IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
  64. protected:
  65. friend class HardwareBufferManager;
  66. IndexBuffer(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage);
  67. /** @copydoc CoreObject::createCore */
  68. virtual SPtr<CoreObjectCore> createCore() const;
  69. IndexBufferProperties mProperties;
  70. GpuBufferUsage mUsage;
  71. };
  72. }