Utils.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <Atom/RHI/Device.h>
  10. #include <Atom/RHI/PipelineState.h>
  11. #include <Atom/RPI.Public/Base.h>
  12. #include <Atom/RPI.Public/Image/StreamingImage.h>
  13. #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
  14. #include <Atom/Feature/ImageBasedLights/ImageBasedLightFeatureProcessorInterface.h>
  15. // Some versions of Visual Studio have a bug that prevents debugging static member.
  16. // https://developercommunity.visualstudio.com/content/problem/25756/cannot-view-static-member-variables-in-debugger.html
  17. #define AZ_DEBUG_STATIC_MEMEBER(localVariable, staticMember) AZStd::add_lvalue_reference<decltype(staticMember)>::type localVariable = staticMember; AZ_UNUSED(localVariable);
  18. namespace AtomSampleViewer
  19. {
  20. namespace Utils
  21. {
  22. AZ::RHI::Ptr<AZ::RHI::Device> GetRHIDevice();
  23. struct AssetEntry
  24. {
  25. AZStd::string m_path;
  26. AZ::Data::AssetId m_assetId;
  27. AZStd::string m_name;
  28. };
  29. /**
  30. * Helper for ImGui
  31. * Used to help display a ListBox of AssetEntries
  32. */
  33. bool AssetEntryNameGetter(void* data, int index, const char** outName);
  34. void ToggleRadTMCapture();
  35. class DefaultIBL
  36. {
  37. public:
  38. DefaultIBL() = default;
  39. ~DefaultIBL();
  40. void PreloadAssets();
  41. void Init(AZ::RPI::Scene* scene);
  42. void SetExposure(float exposure);
  43. void Reset();
  44. private:
  45. AZ::Render::ImageBasedLightFeatureProcessorInterface* m_featureProcessor = nullptr;
  46. AZ::Data::Asset<AZ::RPI::StreamingImageAsset> m_diffuseImageAsset;
  47. AZ::Data::Asset<AZ::RPI::StreamingImageAsset> m_specularImageAsset;
  48. };
  49. bool SupportsResizeClientArea();
  50. void ResizeClientArea(uint32_t width, uint32_t height);
  51. bool SupportsToggleFullScreenOfDefaultWindow();
  52. void ToggleFullScreenOfDefaultWindow();
  53. void ReportScriptableAction(const char* formatStr, ...);
  54. bool RunDiffTool(const AZStd::string& filePathA, const AZStd::string& filePathB);
  55. AZ::Data::Instance<AZ::RPI::StreamingImage> GetSolidColorCubemap(uint32_t color);
  56. //! Provides a more convenient way to call AZ::IO::FileIOBase::GetInstance()->ResolvePath()
  57. AZStd::string ResolvePath(const AZStd::string& path);
  58. //! Returns true if the file resides within a folder
  59. bool IsFileUnderFolder(AZStd::string filePath, AZStd::string folder);
  60. } // namespace Utils
  61. } // namespace AtomSampleViewer