BsScriptProfilerOverlayInternal.cpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "Wrappers/BsScriptProfilerOverlayInternal.h"
  4. #include "BsScriptMeta.h"
  5. #include "BsMonoField.h"
  6. #include "BsMonoClass.h"
  7. #include "BsMonoManager.h"
  8. #include "BsMonoUtil.h"
  9. #include "BsApplication.h"
  10. #include "Renderer/BsCamera.h"
  11. #include "Wrappers/BsScriptCamera.h"
  12. namespace bs
  13. {
  14. ScriptProfilerOverlayInternal::ScriptProfilerOverlayInternal(MonoObject* managedInstance, const SPtr<Camera>& camera)
  15. :ScriptObject(managedInstance), mProfilerOverlayInternal(nullptr)
  16. {
  17. if (camera != nullptr)
  18. mProfilerOverlayInternal = bs_new<ProfilerOverlayInternal>(camera);
  19. }
  20. ScriptProfilerOverlayInternal::~ScriptProfilerOverlayInternal()
  21. {
  22. if (mProfilerOverlayInternal != nullptr)
  23. bs_delete(mProfilerOverlayInternal);
  24. }
  25. void ScriptProfilerOverlayInternal::initRuntimeData()
  26. {
  27. metaData.scriptClass->addInternalCall("Internal_CreateInstance", (void*)&ScriptProfilerOverlayInternal::internal_CreateInstance);
  28. metaData.scriptClass->addInternalCall("Internal_SetType", (void*)&ScriptProfilerOverlayInternal::internal_SetType);
  29. metaData.scriptClass->addInternalCall("Internal_Update", (void*)&ScriptProfilerOverlayInternal::internal_Update);
  30. metaData.scriptClass->addInternalCall("Internal_DestroyInstance", (void*)&ScriptProfilerOverlayInternal::internal_DestroyInstance);
  31. }
  32. void ScriptProfilerOverlayInternal::internal_CreateInstance(MonoObject* instance, ScriptCamera* camera)
  33. {
  34. SPtr<Camera> nativeCamera;
  35. if (camera != nullptr)
  36. nativeCamera = camera->getInternal();
  37. new (bs_alloc<ScriptProfilerOverlayInternal>()) ScriptProfilerOverlayInternal(instance, nativeCamera);
  38. }
  39. void ScriptProfilerOverlayInternal::internal_SetType(ScriptProfilerOverlayInternal* thisPtr, ProfilerOverlayType type)
  40. {
  41. if (thisPtr->mProfilerOverlayInternal != nullptr)
  42. thisPtr->mProfilerOverlayInternal->show(type);
  43. }
  44. void ScriptProfilerOverlayInternal::internal_Update(ScriptProfilerOverlayInternal* thisPtr)
  45. {
  46. if (thisPtr->mProfilerOverlayInternal != nullptr)
  47. thisPtr->mProfilerOverlayInternal->update();
  48. }
  49. void ScriptProfilerOverlayInternal::internal_DestroyInstance(ScriptProfilerOverlayInternal* thisPtr)
  50. {
  51. if (thisPtr->mProfilerOverlayInternal != nullptr)
  52. {
  53. bs_delete(thisPtr->mProfilerOverlayInternal);
  54. thisPtr->mProfilerOverlayInternal = nullptr;
  55. }
  56. }
  57. }