IVertexBuffer.h 2.9 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. #ifndef IRR_I_VERTEX_BUFFER_H_INCLUDED
  5. #define IRR_I_VERTEX_BUFFER_H_INCLUDED
  6. #include "IReferenceCounted.h"
  7. #include "irrArray.h"
  8. #include "EHardwareBufferFlags.h"
  9. #include "S3DVertex.h"
  10. namespace irr
  11. {
  12. namespace scene
  13. {
  14. class IVertexBuffer : public virtual IReferenceCounted
  15. {
  16. public:
  17. //! Pointer to first element of vertex data
  18. virtual void* getData() =0;
  19. //! Const pointer to first element
  20. virtual const void* getData() const =0;
  21. //! Same as getData.
  22. virtual void* pointer() { return getData(); }
  23. virtual video::E_VERTEX_TYPE getType() const =0;
  24. virtual void setType(video::E_VERTEX_TYPE vertexType) =0;
  25. //! Number of bytes per element
  26. virtual u32 stride() const =0;
  27. //! Number of elements
  28. virtual u32 size() const =0;
  29. //! Add vertex to end.
  30. //* Note that if you pass another type than the currently used vertex type then information can be lost */
  31. virtual void push_back(const video::S3DVertex &element) =0;
  32. virtual void push_back(const video::S3DVertex2TCoords &element) =0;
  33. virtual void push_back(const video::S3DVertexTangents &element) =0;
  34. //! Set value at index. Buffer must be already large enough that element exists.
  35. //* Note that if you pass another type than the currently used vertex type then information can be lost */
  36. virtual void setValue(u32 index, const video::S3DVertex &value) =0;
  37. virtual void setValue(u32 index, const video::S3DVertex2TCoords &value) =0;
  38. virtual void setValue(u32 index, const video::S3DVertexTangents &value) =0;
  39. //! Direct access to elements. Risky to use!
  40. /** The reference _must_ be cast to the correct type before use. It's only video::S3DVertex if getType is EVT_STANDARD.
  41. otherwise cast it first to a reference type derived from S3DVertex like S3DVertex2TCoords& or S3DVertexTangents&. */
  42. virtual video::S3DVertex& operator [](u32 index) = 0;
  43. virtual video::S3DVertex& operator [](const u32 index) const =0;
  44. virtual video::S3DVertex& getLast() =0;
  45. virtual void set_used(u32 usedNow) =0;
  46. virtual void reallocate(u32 new_size, bool canShrink=true) =0;
  47. virtual u32 allocated_size() const =0;
  48. //! get the current hardware mapping hint
  49. virtual E_HARDWARE_MAPPING getHardwareMappingHint() const =0;
  50. //! set the hardware mapping hint, for driver
  51. virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint ) =0;
  52. //! flags the meshbuffer as changed, reloads hardware buffers
  53. virtual void setDirty() =0;
  54. //! Get the currently used ID for identification of changes.
  55. /** This shouldn't be used for anything outside the VideoDriver. */
  56. virtual u32 getChangedID() const = 0;
  57. };
  58. } // end namespace scene
  59. } // end namespace irr
  60. #endif