CmD3D9VertexDeclaration.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. -----------------------------------------------------------------------------
  3. This source file is part of OGRE
  4. (Object-oriented Graphics Rendering Engine)
  5. For the latest info, see http://www.ogre3d.org/
  6. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #ifndef __D3D9VERTEXDECLARATION_H__
  25. #define __D3D9VERTEXDECLARATION_H__
  26. #include "CmD3D9Prerequisites.h"
  27. #include "CmHardwareVertexBuffer.h"
  28. #include "CmD3D9Resource.h"
  29. namespace CamelotEngine {
  30. /** Specialisation of VertexDeclaration for D3D9 */
  31. class _OgreD3D9Export D3D9VertexDeclaration : public VertexDeclaration, public D3D9Resource
  32. {
  33. public:
  34. D3D9VertexDeclaration();
  35. ~D3D9VertexDeclaration();
  36. /** See VertexDeclaration */
  37. const VertexElement& addElement(unsigned short source, size_t offset, VertexElementType theType,
  38. VertexElementSemantic semantic, unsigned short index = 0);
  39. /** See VertexDeclaration */
  40. const VertexElement& insertElement(unsigned short atPosition,
  41. unsigned short source, size_t offset, VertexElementType theType,
  42. VertexElementSemantic semantic, unsigned short index = 0);
  43. /** See VertexDeclaration */
  44. void removeElement(unsigned short elem_index);
  45. /** See VertexDeclaration */
  46. void removeElement(VertexElementSemantic semantic, unsigned short index = 0);
  47. /** See VertexDeclaration */
  48. void removeAllElements(void);
  49. /** See VertexDeclaration */
  50. void modifyElement(unsigned short elem_index, unsigned short source, size_t offset, VertexElementType theType,
  51. VertexElementSemantic semantic, unsigned short index = 0);
  52. // Called immediately after the Direct3D device has been created.
  53. virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
  54. // Called before the Direct3D device is going to be destroyed.
  55. virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
  56. /** Gets the D3D9-specific vertex declaration. */
  57. IDirect3DVertexDeclaration9* getD3DVertexDeclaration(void);
  58. protected:
  59. void releaseDeclaration();
  60. protected:
  61. typedef map<IDirect3DDevice9*, IDirect3DVertexDeclaration9*>::type DeviceToDeclarationMap;
  62. typedef DeviceToDeclarationMap::iterator DeviceToDeclarationIterator;
  63. DeviceToDeclarationMap mMapDeviceToDeclaration;
  64. };
  65. }
  66. #endif