MCPcopy Create free account
hub / github.com/MethanePowered/MethaneKit / HelloCubeApp

Class HelloCubeApp

Apps/02-HelloCube/HelloCubeApp.cpp:62–298  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60
61using GraphicsApp = App<HelloCubeFrame>;
62class HelloCubeApp final // NOSONAR - destructor required
63 : public GraphicsApp
64{
65private:
66 struct CubeVertex
67 {
68 Mesh::Position position;
69 Mesh::Color color;
70
71 inline static const Mesh::VertexLayout layout{
72 Mesh::VertexField::Position,
73 Mesh::VertexField::Color
74 };
75 };
76
77 const CubeMesh<CubeVertex> m_cube_mesh{ CubeVertex::layout };
78 const hlslpp::float4x4 m_model_matrix = hlslpp::float4x4::scale(15.F);
79 Camera m_camera;
80
81#ifdef UNIFORMS_ENABLED
82 Rhi::BufferSet m_vertex_buffer_set;
83#else
84 std::vector<CubeVertex> m_proj_vertices;
85#endif
86
87 Rhi::CommandQueue m_render_cmd_queue;
88 Rhi::RenderState m_render_state;
89 Rhi::Buffer m_index_buffer;
90
91public:
92 HelloCubeApp()
93 : GraphicsApp(
94 []() {
95 Graphics::CombinedAppSettings settings = Tutorials::GetGraphicsTutorialAppSettings(g_app_name, Tutorials::AppOptions::GetDefaultWithColorOnlyAndAnim());
96#ifdef UNIFORMS_ENABLED
97 settings.graphics_app.SetScreenPassAccess(Rhi::RenderPassAccessMask(Rhi::RenderPassAccess::ShaderResources));
98#else
99 settings.graphics_app.SetScreenPassAccess({});
100#endif
101 return settings;
102 }(),
103 "Tutorial demonstrating colored rotating cube rendering with Methane Kit.")
104#ifndef UNIFORMS_ENABLED
105 , m_proj_vertices(m_cube_mesh.GetVertices())
106#endif
107 {
108 m_camera.ResetOrientation({ { 13.0F, 13.0F, 13.0F }, { 0.0F, 0.0F, 0.0F }, { 0.0F, 1.0F, 0.0F } });
109
110 // Setup camera rotation animation
111 GetAnimations().emplace_back(Data::MakeTimeAnimationPtr([this](double, double delta_seconds)
112 {
113 m_camera.Rotate(m_camera.GetOrientation().up, static_cast<float>(delta_seconds * 360.F / 8.F));
114 return true;
115 }));
116 }
117
118 ~HelloCubeApp() override
119 {

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected