2
0

IIndexBuffer.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Copyright (C) 2008-2012 Nikolaus Gebhardt
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #pragma once
  5. #include "IReferenceCounted.h"
  6. #include "EHardwareBufferFlags.h"
  7. #include "EPrimitiveTypes.h"
  8. #include "SVertexIndex.h"
  9. namespace irr
  10. {
  11. namespace scene
  12. {
  13. class IIndexBuffer : public virtual IReferenceCounted
  14. {
  15. public:
  16. //! Get type of index data which is stored in this meshbuffer.
  17. /** \return Index type of this buffer. */
  18. virtual video::E_INDEX_TYPE getType() const = 0;
  19. //! Get access to indices.
  20. /** \return Pointer to indices array. */
  21. virtual const void *getData() const = 0;
  22. //! Get access to indices.
  23. /** \return Pointer to indices array. */
  24. virtual void *getData() = 0;
  25. //! Get amount of indices in this meshbuffer.
  26. /** \return Number of indices in this buffer. */
  27. virtual u32 getCount() const = 0;
  28. //! get the current hardware mapping hint
  29. virtual E_HARDWARE_MAPPING getHardwareMappingHint() const = 0;
  30. //! set the hardware mapping hint, for driver
  31. virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint) = 0;
  32. //! flags the meshbuffer as changed, reloads hardware buffers
  33. virtual void setDirty() = 0;
  34. //! Get the currently used ID for identification of changes.
  35. /** This shouldn't be used for anything outside the VideoDriver. */
  36. virtual u32 getChangedID() const = 0;
  37. //! Used by the VideoDriver to remember the buffer link.
  38. virtual void setHWBuffer(void *ptr) const = 0;
  39. virtual void *getHWBuffer() const = 0;
  40. //! Calculate how many geometric primitives would be drawn
  41. u32 getPrimitiveCount(E_PRIMITIVE_TYPE primitiveType) const
  42. {
  43. const u32 indexCount = getCount();
  44. switch (primitiveType) {
  45. case scene::EPT_POINTS:
  46. return indexCount;
  47. case scene::EPT_LINE_STRIP:
  48. return indexCount - 1;
  49. case scene::EPT_LINE_LOOP:
  50. return indexCount;
  51. case scene::EPT_LINES:
  52. return indexCount / 2;
  53. case scene::EPT_TRIANGLE_STRIP:
  54. return (indexCount - 2);
  55. case scene::EPT_TRIANGLE_FAN:
  56. return (indexCount - 2);
  57. case scene::EPT_TRIANGLES:
  58. return indexCount / 3;
  59. case scene::EPT_POINT_SPRITES:
  60. return indexCount;
  61. }
  62. return 0;
  63. }
  64. };
  65. } // end namespace scene
  66. } // end namespace irr