2
0

IIndexBuffer.h 2.2 KB

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