2
0

Utils.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 <AzFramework/Windowing/WindowBus.h>
  10. #include <Atom/RHI/Device.h>
  11. #include <Atom/RHI/PipelineState.h>
  12. #include <Atom/RPI.Public/Base.h>
  13. #include <Atom/RPI.Public/Image/StreamingImage.h>
  14. #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
  15. #include <Atom/Feature/ImageBasedLights/ImageBasedLightFeatureProcessorInterface.h>
  16. // Some versions of Visual Studio have a bug that prevents debugging static member.
  17. // https://developercommunity.visualstudio.com/content/problem/25756/cannot-view-static-member-variables-in-debugger.html
  18. #define AZ_DEBUG_STATIC_MEMEBER(localVariable, staticMember) AZStd::add_lvalue_reference<decltype(staticMember)>::type localVariable = staticMember; AZ_UNUSED(localVariable);
  19. namespace AtomSampleViewer
  20. {
  21. namespace Utils
  22. {
  23. AZ::RHI::Ptr<AZ::RHI::Device> GetRHIDevice();
  24. struct AssetEntry
  25. {
  26. AZStd::string m_path;
  27. AZ::Data::AssetId m_assetId;
  28. AZStd::string m_name;
  29. };
  30. /**
  31. * Helper for ImGui
  32. * Used to help display a ListBox of AssetEntries
  33. */
  34. bool AssetEntryNameGetter(void* data, int index, const char** outName);
  35. void ToggleRadTMCapture();
  36. class DefaultIBL
  37. {
  38. public:
  39. DefaultIBL() = default;
  40. ~DefaultIBL();
  41. void PreloadAssets();
  42. void Init(AZ::RPI::Scene* scene);
  43. void SetExposure(float exposure);
  44. void Reset();
  45. private:
  46. AZ::Render::ImageBasedLightFeatureProcessorInterface* m_featureProcessor = nullptr;
  47. AZ::Data::Asset<AZ::RPI::StreamingImageAsset> m_diffuseImageAsset;
  48. AZ::Data::Asset<AZ::RPI::StreamingImageAsset> m_specularImageAsset;
  49. };
  50. bool SupportsResizeClientArea();
  51. void ResizeClientArea(uint32_t width, uint32_t height, const AzFramework::WindowPosOptions& options);
  52. bool SupportsToggleFullScreenOfDefaultWindow();
  53. void ToggleFullScreenOfDefaultWindow();
  54. void ReportScriptableAction(const char* formatStr, ...);
  55. // Discovers, from the settings registry, the path to the diff tool and invokes
  56. // the per-platform RunDiffTool_Impl.
  57. bool RunDiffTool(const AZStd::string& filePathA, const AZStd::string& filePathB);
  58. // Customized per platform
  59. AZStd::string GetDefaultDiffToolPath_Impl();
  60. bool RunDiffTool_Impl(const AZStd::string& diffToolPath, const AZStd::string& filePathA, const AZStd::string& filePathB);
  61. AZ::Data::Instance<AZ::RPI::StreamingImage> GetSolidColorCubemap(uint32_t color);
  62. //! Provides a more convenient way to call AZ::IO::FileIOBase::GetInstance()->ResolvePath()
  63. AZStd::string ResolvePath(const AZStd::string& path);
  64. //! Returns true if the file resides within a folder
  65. bool IsFileUnderFolder(AZStd::string filePath, AZStd::string folder);
  66. } // namespace Utils
  67. } // namespace AtomSampleViewer