CmDepthStencilStateRTTI.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmRTTIType.h"
  4. #include "CmDepthStencilState.h"
  5. #include "CmRenderStateManager.h"
  6. namespace CamelotFramework
  7. {
  8. class CM_EXPORT DepthStencilStateRTTI : public RTTIType<DepthStencilState, IReflectable, DepthStencilStateRTTI>
  9. {
  10. private:
  11. DEPTH_STENCIL_STATE_DESC& getData(DepthStencilState* obj) { return obj->mData; }
  12. void setData(DepthStencilState* obj, DEPTH_STENCIL_STATE_DESC& val)
  13. {
  14. obj->mRTTIData = val;
  15. }
  16. public:
  17. DepthStencilStateRTTI()
  18. {
  19. addPlainField("mData", 0, &DepthStencilStateRTTI::getData, &DepthStencilStateRTTI::setData);
  20. }
  21. virtual void onDeserializationEnded(IReflectable* obj)
  22. {
  23. DepthStencilState* depthStencilState = static_cast<DepthStencilState*>(obj);
  24. if(!depthStencilState->mRTTIData.empty())
  25. {
  26. DEPTH_STENCIL_STATE_DESC desc = boost::any_cast<DEPTH_STENCIL_STATE_DESC>(depthStencilState->mRTTIData);
  27. depthStencilState->initialize(desc);
  28. }
  29. }
  30. virtual const String& getRTTIName()
  31. {
  32. static String name = "DepthStencilState";
  33. return name;
  34. }
  35. virtual UINT32 getRTTIId()
  36. {
  37. return TID_DepthStencilState;
  38. }
  39. virtual std::shared_ptr<IReflectable> newRTTIObject()
  40. {
  41. return RenderStateManager::instance().createEmptyDepthStencilState();
  42. }
  43. };
  44. }