Triangle posting
https://vulkan-tutorial.com/Vertex_buffers/Staging_buffer Reached the above part of the tutorial. Adding IMGUI now before continuing.
This commit is contained in:
58
src/main.cpp
Normal file → Executable file
58
src/main.cpp
Normal file → Executable file
@@ -1,27 +1,27 @@
|
||||
|
||||
#include "Logger.h"
|
||||
#include "VulkanInstanceManager.h"
|
||||
#include "VulkanDeviceManager.h"
|
||||
#include "VulkanDebugManager.h"
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
#include "utilities/Logger.h"
|
||||
#include "GlfwWindowManager.h"
|
||||
#include "VulkanGraphicsPipeline.h"
|
||||
// #include "VulkanContext.h"
|
||||
#include "VulkanContext.h"
|
||||
|
||||
struct AppConfig
|
||||
{
|
||||
std::string Title = "Learning Vulkan";
|
||||
uint32_t Width = 800;
|
||||
uint32_t Height = 600;
|
||||
bool bResizable = false;
|
||||
bool bResizable = true;
|
||||
bool bFullscreen = false;
|
||||
bool bValidationEnabled = true;
|
||||
bool bValidationEnabled = false;
|
||||
bool bVerboseLogging = false;
|
||||
};
|
||||
|
||||
void test () {
|
||||
if (true) return;
|
||||
|
||||
}
|
||||
const std::vector<Vertex> TriangleVertices = {
|
||||
{ { 0.0f, -0.5f }, { 1.0f, 1.0f, 1.0f } },
|
||||
{ { 0.5f, 0.5f }, { 0.0f, 1.0f, 0.0f } },
|
||||
{ { -0.5f, 0.5f }, { 0.0f, 0.0f, 1.0f } }
|
||||
};
|
||||
|
||||
class HelloTriangleApplication
|
||||
{
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
void Run()
|
||||
{
|
||||
Initialization();
|
||||
Log::Info("Initialization finished...");
|
||||
MainLoop();
|
||||
Cleanup();
|
||||
}
|
||||
@@ -36,25 +37,24 @@ public:
|
||||
private:
|
||||
AppConfig Settings = {};
|
||||
|
||||
VulkanInstanceManager InstanceManager;
|
||||
GlfwWindowManager WindowManager;
|
||||
GlfwWindowManager WindowManager;
|
||||
VulkanContext VkContext;
|
||||
|
||||
void Initialization()
|
||||
{
|
||||
InitGlfw();
|
||||
InitVulkan();
|
||||
InstanceManager.SetupDebug();
|
||||
WindowManager.CreateSurface(InstanceManager.GetInstance());
|
||||
InstanceManager.SetupDevice();
|
||||
}
|
||||
|
||||
void InitVulkan()
|
||||
{
|
||||
FVulkanConfig Config = {
|
||||
Settings.bValidationEnabled,
|
||||
Settings.bVerboseLogging
|
||||
Settings.bVerboseLogging,
|
||||
WindowManager.GetWindow(),
|
||||
TriangleVertices
|
||||
};
|
||||
InstanceManager.Initialize(Config);
|
||||
VkContext.Initialize(Config);
|
||||
}
|
||||
|
||||
void InitGlfw()
|
||||
@@ -67,6 +67,20 @@ private:
|
||||
Settings.bFullscreen
|
||||
};
|
||||
WindowManager.Initialize(Config);
|
||||
|
||||
glfwSetWindowUserPointer(WindowManager.GetWindow(), this);
|
||||
glfwSetFramebufferSizeCallback(WindowManager.GetWindow(), FramebufferResizeCallback);
|
||||
}
|
||||
|
||||
static void FramebufferResizeCallback(GLFWwindow* Window, int Width, int Height)
|
||||
{
|
||||
auto App = reinterpret_cast<HelloTriangleApplication*>(glfwGetWindowUserPointer(Window));
|
||||
App->VkContext.SetFramebufferResized(true);
|
||||
}
|
||||
|
||||
void DrawFrame()
|
||||
{
|
||||
VkContext.DrawFrame();
|
||||
}
|
||||
|
||||
void MainLoop()
|
||||
@@ -74,13 +88,15 @@ private:
|
||||
while (!WindowManager.ShouldClose())
|
||||
{
|
||||
WindowManager.PollEvents();
|
||||
DrawFrame();
|
||||
}
|
||||
}
|
||||
|
||||
void Cleanup()
|
||||
{
|
||||
WindowManager.Cleanup(InstanceManager.GetInstance());
|
||||
InstanceManager.Cleanup();
|
||||
Log::Info("Cleaning up...");
|
||||
VkContext.Cleanup();
|
||||
WindowManager.Cleanup();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user