D3D9VertexDeclaration.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright (c) 2008-2022 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include "../../Container/Ptr.h"
  5. #include "../../Container/Vector.h"
  6. #include "../../GraphicsAPI/GraphicsDefs.h"
  7. #include <d3d9.h>
  8. namespace Urho3D
  9. {
  10. class Graphics;
  11. class VertexBuffer;
  12. /// One element in a vertex declaration. In contrast to the VertexElement structure, takes into account the stream source index.
  13. struct VertexDeclarationElement_D3D9
  14. {
  15. /// Element type.
  16. VertexElementType type_;
  17. /// Element semantic.
  18. VertexElementSemantic semantic_;
  19. /// Semantic index.
  20. unsigned char index_;
  21. /// Stream index.
  22. unsigned char streamIndex_;
  23. /// Byte offset.
  24. unsigned offset_;
  25. };
  26. /// Vertex declaration.
  27. class URHO3D_API VertexDeclaration_D3D9 : public RefCounted
  28. {
  29. public:
  30. /// Construct with a single buffer's vertex element list.
  31. VertexDeclaration_D3D9(Graphics* graphics, const PODVector<VertexElement>& srcElements);
  32. /// Construct with vertex buffers to base declaration on. Higher index buffers will override semantics on lower indices.
  33. VertexDeclaration_D3D9(Graphics* graphics, const PODVector<VertexBuffer*>& buffers);
  34. /// Construct with vertex buffers (shared pointer vector) to base declaration on. Higher index buffers will override semantics on lower indices.
  35. VertexDeclaration_D3D9(Graphics* graphics, const Vector<SharedPtr<VertexBuffer>>& buffers);
  36. /// Destruct.
  37. ~VertexDeclaration_D3D9();
  38. /// Return Direct3D vertex declaration.
  39. IDirect3DVertexDeclaration9* GetDeclaration() const { return declaration_; }
  40. private:
  41. /// Create declaration.
  42. void Create(Graphics* graphics, const PODVector<VertexDeclarationElement_D3D9>& elements);
  43. /// Release declaration.
  44. void Release();
  45. /// Direct3D vertex declaration.
  46. IDirect3DVertexDeclaration9* declaration_;
  47. };
  48. }