BsRenderTarget.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #include "BsRenderTarget.h"
  2. #include "BsViewport.h"
  3. #include "BsException.h"
  4. #include "BsRenderAPI.h"
  5. #include "BsCoreThread.h"
  6. #include "BsFrameAlloc.h"
  7. namespace BansheeEngine
  8. {
  9. RenderTargetCore::RenderTargetCore()
  10. {
  11. }
  12. void RenderTargetCore::setActive(bool state)
  13. {
  14. RenderTargetProperties& props = const_cast<RenderTargetProperties&>(getProperties());
  15. props.mActive = state;
  16. markCoreDirty();
  17. }
  18. void RenderTargetCore::setPriority(INT32 priority)
  19. {
  20. RenderTargetProperties& props = const_cast<RenderTargetProperties&>(getProperties());
  21. props.mPriority = priority;
  22. markCoreDirty();
  23. }
  24. const RenderTargetProperties& RenderTargetCore::getProperties() const
  25. {
  26. return getPropertiesInternal();
  27. }
  28. void RenderTargetCore::getCustomAttribute(const String& name, void* pData) const
  29. {
  30. BS_EXCEPT(InvalidParametersException, "Attribute not found.");
  31. }
  32. RenderTarget::RenderTarget()
  33. {
  34. // We never sync from sim to core, so mark it clean to avoid overwriting core thread changes
  35. markCoreClean();
  36. }
  37. void RenderTarget::setPriority(CoreAccessor& accessor, INT32 priority)
  38. {
  39. std::function<void(SPtr<RenderTargetCore>, INT32)> windowedFunc =
  40. [](SPtr<RenderTargetCore> renderTarget, INT32 priority)
  41. {
  42. renderTarget->setPriority(priority);
  43. };
  44. accessor.queueCommand(std::bind(windowedFunc, getCore(), priority));
  45. }
  46. SPtr<RenderTargetCore> RenderTarget::getCore() const
  47. {
  48. return std::static_pointer_cast<RenderTargetCore>(mCoreSpecific);
  49. }
  50. const RenderTargetProperties& RenderTarget::getProperties() const
  51. {
  52. THROW_IF_CORE_THREAD;
  53. return getPropertiesInternal();
  54. }
  55. void RenderTarget::getCustomAttribute(const String& name, void* pData) const
  56. {
  57. BS_EXCEPT(InvalidParametersException, "Attribute not found.");
  58. }
  59. }