DynamicDrawExampleComponent.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
  3. * its licensors.
  4. *
  5. * For complete copyright and license terms please see the LICENSE at the root of this
  6. * distribution (the "License"). All use of this software is governed by the License,
  7. * or, if provided, by the license below or the license accompanying this file. Do not
  8. * remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
  9. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. *
  11. */
  12. #pragma once
  13. #include <CommonSampleComponentBase.h>
  14. #include <AzCore/Component/TickBus.h>
  15. #include <Atom/RPI.Public/Buffer/Buffer.h>
  16. #include <Atom/RPI.Public/DynamicDraw/DynamicDrawContext.h>
  17. #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
  18. #include <Atom/RHI/StreamBufferView.h>
  19. #include <Atom/RHI/IndexBufferView.h>
  20. #include <Atom/RHI/PipelineState.h>
  21. #include <Atom/RHI/DrawList.h>
  22. #include <Utils/ImGuiSidebar.h>
  23. namespace AtomSampleViewer
  24. {
  25. //! Provides a basic example for how to use DynamicDrawInterface and DynamicDrawContext
  26. class DynamicDrawExampleComponent final
  27. : public CommonSampleComponentBase
  28. , public AZ::TickBus::Handler
  29. {
  30. public:
  31. AZ_COMPONENT(DynamicDrawExampleComponent, "{0BA35CA5-31A4-422B-A269-E138EDD0BB5F}", CommonSampleComponentBase);
  32. static void Reflect(AZ::ReflectContext* context);
  33. DynamicDrawExampleComponent();
  34. ~DynamicDrawExampleComponent() override = default;
  35. // AZ::Component overrides ...
  36. void Activate() override;
  37. void Deactivate() override;
  38. // AZ::TickBus::Handler overrides ...
  39. void OnTick(float deltaTime, AZ::ScriptTimePoint timePoint) override;
  40. private:
  41. struct ExampleVertex
  42. {
  43. float x, y, z;
  44. float r, g, b, a;
  45. };
  46. AZ::RHI::Ptr<AZ::RPI::DynamicDrawContext> m_dynamicDraw;
  47. AZ::Data::Instance<AZ::RPI::ShaderResourceGroup> m_contextSrg;
  48. ImGuiSidebar m_imguiSidebar;
  49. bool m_showCullModeNull = true;
  50. bool m_showCullModeFront = true;
  51. bool m_showCullModeBack = true;
  52. bool m_showAlphaBlend = true;
  53. bool m_showAlphaAdditive = true;
  54. bool m_showLineList = true;
  55. bool m_showPerDrawViewport = true;
  56. // CommonSampleComponentBase overrides...
  57. void OnAllAssetsReadyActivate() override;
  58. };
  59. } // namespace AtomSampleViewer