Repository navigation
Expand file tree
/
Copy pathVulkanApplication.h
More file actions
100 lines (73 loc) · 2.55 KB
/
Copy pathVulkanApplication.h
File metadata and controls
100 lines (73 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* @file VulkanApplication.h
* @brief This file contains VulkanApplication class declaration.
* @author Mustafa Yemural (myemural)
* @date 09.09.2025
*
* Copyright (c) 2025 Mustafa Yemural - www.mustafayemural.com
* Released under the MIT License
* https://opensource.org/licenses/MIT
*/
#pragma once
#include <array>
#include <memory>
#include "ApplicationData.h"
#include "ApplicationDrawing3D.h"
#include "AssetManager.h"
#include "TextureAsset.h"
#include "VulkanCommandBuffer.h"
#include "VulkanPipeline.h"
#include "VulkanPipelineLayout.h"
#include "Window.h"
namespace examples::fundamentals::drawing_3d::basic_camera_control
{
class VulkanApplication final : public base::ApplicationDrawing3D
{
public:
explicit VulkanApplication(common::utility::ParameterServer&& params);
~VulkanApplication() override = default;
protected:
bool Init() override;
void DrawFrame() override;
void PreUpdate() override;
private:
void InitInputSystem();
void InitAssetManager();
void CreateResources();
void InitResources();
void CreateRenderPass();
void CreatePipeline();
void UpdateDescriptorSets();
void CreateCommandBuffers();
void RecordPresentCommandBuffers(std::uint32_t currentImageIndex);
void CalculateAndSetMvp();
void ProcessInput();
std::uint32_t currentIndex_ = 0;
std::uint32_t currentWindowWidth_ = UINT32_MAX;
std::uint32_t currentWindowHeight_ = UINT32_MAX;
VkFormat depthImageFormat_ = VK_FORMAT_UNDEFINED;
std::array<MvpData, NUM_CUBES> mvpData_ = {glm::mat4(1.0)};
// Texture resource
common::asset_manager::TextureAsset crateTextureAsset_{};
// Pipelines
std::shared_ptr<common::vulkan_wrapper::VulkanPipelineLayout> pipelineLayout_;
std::shared_ptr<common::vulkan_wrapper::VulkanPipeline> pipeline_;
// Command buffers
std::vector<std::shared_ptr<common::vulkan_wrapper::VulkanCommandBuffer>> cmdBuffersPresent_;
// Asset manager
std::unique_ptr<common::asset_manager::AssetManager> assetManager_;
// Camera values
glm::vec3 cameraPos_ = glm::vec3(0.0f, 0.0f, 4.0f);
glm::vec3 cameraFront_ = glm::vec3(0.0f, 0.0f, -1.0f);
glm::vec3 cameraUp_ = glm::vec3(0.0f, 1.0f, 0.0f);
// Delta time related values
double deltaTime_ = 0.0f;
double lastFrame_ = 0.0f;
// Mouse related values
bool firstMouseTriggered_ = true;
float yawAngle_ = -90.0f;
float pitchAngle_ = 0.0f;
float lastX_ = 0.0f;
float lastY_ = 0.0f;
};
} // namespace examples::fundamentals::drawing_3d::basic_camera_control