First commit from Arch
This commit is contained in:
102
src/main.cpp
Normal file
102
src/main.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
|
||||
#include "Logger.h"
|
||||
#include "VulkanInstanceManager.h"
|
||||
#include "VulkanDeviceManager.h"
|
||||
#include "VulkanDebugManager.h"
|
||||
#include "GlfwWindowManager.h"
|
||||
#include "VulkanGraphicsPipeline.h"
|
||||
// #include "VulkanContext.h"
|
||||
|
||||
struct AppConfig
|
||||
{
|
||||
std::string Title = "Learning Vulkan";
|
||||
uint32_t Width = 800;
|
||||
uint32_t Height = 600;
|
||||
bool bResizable = false;
|
||||
bool bFullscreen = false;
|
||||
bool bValidationEnabled = true;
|
||||
bool bVerboseLogging = false;
|
||||
};
|
||||
|
||||
void test () {
|
||||
if (true) return;
|
||||
|
||||
}
|
||||
|
||||
class HelloTriangleApplication
|
||||
{
|
||||
public:
|
||||
void Run()
|
||||
{
|
||||
Initialization();
|
||||
MainLoop();
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
private:
|
||||
AppConfig Settings = {};
|
||||
|
||||
VulkanInstanceManager InstanceManager;
|
||||
GlfwWindowManager WindowManager;
|
||||
|
||||
void Initialization()
|
||||
{
|
||||
InitGlfw();
|
||||
InitVulkan();
|
||||
InstanceManager.SetupDebug();
|
||||
WindowManager.CreateSurface(InstanceManager.GetInstance());
|
||||
InstanceManager.SetupDevice();
|
||||
}
|
||||
|
||||
void InitVulkan()
|
||||
{
|
||||
FVulkanConfig Config = {
|
||||
Settings.bValidationEnabled,
|
||||
Settings.bVerboseLogging
|
||||
};
|
||||
InstanceManager.Initialize(Config);
|
||||
}
|
||||
|
||||
void InitGlfw()
|
||||
{
|
||||
FWindowConfig Config = {
|
||||
Settings.Title,
|
||||
Settings.Width,
|
||||
Settings.Height,
|
||||
Settings.bResizable,
|
||||
Settings.bFullscreen
|
||||
};
|
||||
WindowManager.Initialize(Config);
|
||||
}
|
||||
|
||||
void MainLoop()
|
||||
{
|
||||
while (!WindowManager.ShouldClose())
|
||||
{
|
||||
WindowManager.PollEvents();
|
||||
}
|
||||
}
|
||||
|
||||
void Cleanup()
|
||||
{
|
||||
WindowManager.Cleanup(InstanceManager.GetInstance());
|
||||
InstanceManager.Cleanup();
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
HelloTriangleApplication app;
|
||||
|
||||
try
|
||||
{
|
||||
app.Run();
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
Log::Error(e.what());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user