-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelloTriangleApplication.h
More file actions
66 lines (52 loc) · 1.75 KB
/
Copy pathHelloTriangleApplication.h
File metadata and controls
66 lines (52 loc) · 1.75 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
#ifndef HELLO_TRIANGLE_H
#define HELLO_TRIANGLE_H
#include <vector>
#include <optional>
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
struct QueueFamilyIndices {
std::optional<uint32_t> graphicsFamily;
bool isComplete() {
return graphicsFamily.has_value();
}
};
class HelloTriangleApplication {
public:
void run();
private:
// VK ralted
void initVulkan();
void createInstance();
bool checkValidationLayerSupport();
void pickPhysicalDevice();
void createLogicalDevice();
bool isDeviceSuitable(const VkPhysicalDevice& device);
std::string getDeviceInfo(const VkPhysicalDevice& device);
QueueFamilyIndices findQueueFamilies(const VkPhysicalDevice& device);
VkInstance m_instance;
VkPhysicalDevice m_physicalDevice = VK_NULL_HANDLE;
VkDevice m_device;
VkQueue m_graphicsQueue;
// VK debug related
VkDebugUtilsMessengerEXT m_debugMessenger;
const std::vector<const char*> m_validationLayers = {
"VK_LAYER_KHRONOS_validation"
};
void setupDebugMessenger();
void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& createInfo);
static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData);
// Program lifecylce
void mainLoop();
bool checkExtensionSupport(const std::vector<const char*>& required_extensions);
std::vector<const char*> getRequiredExtensions();
void cleanup();
// GLFW related
void initWindow();
GLFWwindow* m_window;
glm::ivec2 m_window_size;
// App related
const bool m_debug = true;
};
#endif //HELLO_TRIANGLE_H