diff --git a/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml b/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
index eb0a5ed..628bf0c 100644
--- a/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
+++ b/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
@@ -5,369 +5,13 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
@@ -381,11 +25,8 @@
-
-
-
-
-
+
+
@@ -515,6 +156,8 @@
+
+
diff --git a/enginecustom/enginecustom.vcxproj b/enginecustom/enginecustom.vcxproj
index e5d4d6e..af24eb0 100644
--- a/enginecustom/enginecustom.vcxproj
+++ b/enginecustom/enginecustom.vcxproj
@@ -585,7 +585,7 @@
true
_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
true
- $(SolutionDir)enginecustom\include\backends;$(SolutionDir)enginecustom\include\Inc;$(SolutionDir)enginecustom\include;$(SolutionDir)enginecustom\src\inc\shader;$(SolutionDir)enginecustom\src\inc\system;%(AdditionalIncludeDirectories)
+ $(SolutionDir)enginecustom\include\backends;$(SolutionDir)enginecustom\include\Inc;$(SolutionDir)enginecustom\include;$(SolutionDir)enginecustom\src\inc\shader;$(SolutionDir)enginecustom\src\inc\system;$(SolutionDir)enginecustom\include\Vulkan\Include;%(AdditionalIncludeDirectories)
stdcpp17
@@ -603,7 +603,7 @@
NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
true
stdcpp17
- $(SolutionDir)enginecustom\include\backends;$(SolutionDir)enginecustom\include\Inc;$(SolutionDir)enginecustom\include;$(SolutionDir)enginecustom\src\inc\shader;$(SolutionDir)enginecustom\src\inc\system;%(AdditionalIncludeDirectories)
+ $(SolutionDir)enginecustom\include\backends;$(SolutionDir)enginecustom\include\Inc;$(SolutionDir)enginecustom\include;$(SolutionDir)enginecustom\src\inc\shader;$(SolutionDir)enginecustom\src\inc\system;$(SolutionDir)enginecustom\include\Vulkan\Include;%(AdditionalIncludeDirectories)
Windows
diff --git a/enginecustom/src/inc/system/applicationclass.h b/enginecustom/src/inc/system/applicationclass.h
index 373ecd3..fa2b16e 100644
--- a/enginecustom/src/inc/system/applicationclass.h
+++ b/enginecustom/src/inc/system/applicationclass.h
@@ -6,6 +6,7 @@
// MY CLASS INCLUDES //
///////////////////////
#include "d3dclass.h"
+#include "vulkan.h"
#include "cameraclass.h"
#include "object.h"
#include "lightclass.h"
@@ -71,7 +72,7 @@ public:
RenderTextureClass* GetReflectionTexture() const { return m_ReflectionTexture; };
- bool Initialize(int, int, HWND);
+ bool Initialize(int, int, HWND, bool IsVulkan);
void Shutdown();
bool Frame(InputClass*);
void PhysicsThreadFunction();
@@ -182,6 +183,7 @@ private :
// ------------------------------------- //
D3DClass* m_Direct3D;
+ VulkanClass* m_Vulkan;
IDXGISwapChain* m_swapChain;
ModelClass* m_Model,* m_GroundModel, * m_WallModel, * m_BathModel, * m_WaterModel;
ModelListClass* m_ModelList;
diff --git a/enginecustom/src/inc/system/vulkan.h b/enginecustom/src/inc/system/vulkan.h
index d64ae41..8815291 100644
--- a/enginecustom/src/inc/system/vulkan.h
+++ b/enginecustom/src/inc/system/vulkan.h
@@ -1,8 +1,49 @@
#pragma once
#include "Vulkan/Include/vulkan/vulkan.h"
+#include
+#include
+#include
+#include "Logger.h"
-class vulkan
-{
+
+class VulkanClass {
public:
-
-};
+ void Initialize(HWND hwnd, int width, int height);
+ void Shutdown();
+ void Render();
+
+private:
+ void CreateInstance();
+ void CreateSurface(HWND hwnd);
+ void PickPhysicalDevice();
+ void CreateLogicalDevice();
+ void CreateSwapChain(int width, int height);
+ void CreateImageViews();
+ void CreateRenderPass();
+ void CreateGraphicsPipeline();
+ void CreateFramebuffers();
+ void CreateCommandPool();
+ void CreateCommandBuffers();
+ void CreateSyncObjects();
+
+ VkInstance instance;
+ VkSurfaceKHR surface;
+ VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
+ VkDevice device;
+ VkQueue graphicsQueue;
+ VkQueue presentQueue;
+ VkSwapchainKHR swapChain;
+ std::vector swapChainImages;
+ VkFormat swapChainImageFormat;
+ VkExtent2D swapChainExtent;
+ std::vector swapChainImageViews;
+ VkRenderPass renderPass;
+ VkPipelineLayout pipelineLayout;
+ VkPipeline graphicsPipeline;
+ std::vector swapChainFramebuffers;
+ VkCommandPool commandPool;
+ std::vector commandBuffers;
+ std::vector imageAvailableSemaphores;
+ std::vector renderFinishedSemaphores;
+ std::vector inFlightFences;
+};
\ No newline at end of file
diff --git a/enginecustom/src/src/system/Systemclass.cpp b/enginecustom/src/src/system/Systemclass.cpp
index d8b3c9a..60f2b08 100644
--- a/enginecustom/src/src/system/Systemclass.cpp
+++ b/enginecustom/src/src/system/Systemclass.cpp
@@ -47,7 +47,7 @@ bool SystemClass::Initialize()
// Create and initialize the application class object. This object will handle rendering all the graphics for this application.
m_Application = new ApplicationClass;
- result = m_Application->Initialize(screenWidth, screenHeight, m_hwnd);
+ result = m_Application->Initialize(screenWidth, screenHeight, m_hwnd, false);
if (!result)
{
return false;
diff --git a/enginecustom/src/src/system/applicationclass.cpp b/enginecustom/src/src/system/applicationclass.cpp
index ead5c51..06aad34 100644
--- a/enginecustom/src/src/system/applicationclass.cpp
+++ b/enginecustom/src/src/system/applicationclass.cpp
@@ -63,11 +63,19 @@ ApplicationClass::~ApplicationClass()
}
-bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
+bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd, bool IsVulkan)
{
Logger::Get().Log("Initializing application class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
+ if (IsVulkan)
+ {
+ m_Vulkan = new VulkanClass();
+ m_Vulkan->Initialize(hwnd, screenWidth, screenHeight);
+
+ return true;
+ }
+
try
{
char mouseString1[32], mouseString2[32], mouseString3[32];
@@ -473,6 +481,13 @@ void ApplicationClass::Shutdown()
{
Logger::Get().Log("Shutting down application class", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
+ if (m_Vulkan)
+ {
+ m_Vulkan->Shutdown();
+ delete m_Vulkan;
+ m_Vulkan = nullptr;
+ }
+
// Release the shader manager object.
if (m_ShaderManager)
{
@@ -697,6 +712,9 @@ void ApplicationClass::Shutdown()
bool ApplicationClass::Frame(InputClass* Input)
{
+
+ m_Vulkan->Render();
+
int mouseX, mouseY, currentMouseX, currentMouseY;
bool result, leftMouseDown, rightMouseDown, buttonQ, buttonD, buttonZ, buttonS, buttonA, buttonE, scrollUp, scrollDown;
float rotationY, rotationX, positionX, positionY, positionZ;
diff --git a/enginecustom/src/src/system/vulkan.cpp b/enginecustom/src/src/system/vulkan.cpp
index 885b93f..327f3aa 100644
--- a/enginecustom/src/src/system/vulkan.cpp
+++ b/enginecustom/src/src/system/vulkan.cpp
@@ -1 +1,98 @@
#include "vulkan.h"
+
+void VulkanClass::Initialize(HWND hwnd, int width, int height) {
+ CreateInstance();
+ CreateSurface(hwnd);
+ PickPhysicalDevice();
+ CreateLogicalDevice();
+ CreateSwapChain(width, height);
+ CreateImageViews();
+ CreateRenderPass();
+ CreateGraphicsPipeline();
+ CreateFramebuffers();
+ CreateCommandPool();
+ CreateCommandBuffers();
+ CreateSyncObjects();
+}
+
+void VulkanClass::Shutdown() {
+ for (size_t i = 0; i < swapChainFramebuffers.size(); i++) {
+ vkDestroyFramebuffer(device, swapChainFramebuffers[i], nullptr);
+ }
+ vkDestroyPipeline(device, graphicsPipeline, nullptr);
+ vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
+ vkDestroyRenderPass(device, renderPass, nullptr);
+ for (size_t i = 0; i < swapChainImageViews.size(); i++) {
+ vkDestroyImageView(device, swapChainImageViews[i], nullptr);
+ }
+ vkDestroySwapchainKHR(device, swapChain, nullptr);
+ vkDestroyDevice(device, nullptr);
+ vkDestroySurfaceKHR(instance, surface, nullptr);
+ vkDestroyInstance(instance, nullptr);
+}
+
+void VulkanClass::Render() {
+ // Rendering code will go here
+}
+
+void VulkanClass::CreateInstance() {
+ VkApplicationInfo appInfo{};
+ appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
+ appInfo.pApplicationName = "Vulkan App";
+ appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
+ appInfo.pEngineName = "No Engine";
+ appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
+ appInfo.apiVersion = VK_API_VERSION_1_0;
+
+ VkInstanceCreateInfo createInfo{};
+ createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
+ createInfo.pApplicationInfo = &appInfo;
+
+ if (vkCreateInstance(&createInfo, nullptr, &instance) != VK_SUCCESS) {
+ throw std::runtime_error("failed to create instance!");
+ }
+}
+
+void VulkanClass::CreateSurface(HWND hwnd) {
+ // Platform-specific surface creation code
+}
+
+void VulkanClass::PickPhysicalDevice() {
+ // Code to pick a suitable physical device
+}
+
+void VulkanClass::CreateLogicalDevice() {
+ // Code to create a logical device
+}
+
+void VulkanClass::CreateSwapChain(int width, int height) {
+ // Code to create a swap chain
+}
+
+void VulkanClass::CreateImageViews() {
+ // Code to create image views
+}
+
+void VulkanClass::CreateRenderPass() {
+ // Code to create a render pass
+}
+
+void VulkanClass::CreateGraphicsPipeline() {
+ // Code to create a graphics pipeline
+}
+
+void VulkanClass::CreateFramebuffers() {
+ // Code to create framebuffers
+}
+
+void VulkanClass::CreateCommandPool() {
+ // Code to create a command pool
+}
+
+void VulkanClass::CreateCommandBuffers() {
+ // Code to create command buffers
+}
+
+void VulkanClass::CreateSyncObjects() {
+ // Code to create synchronization objects
+}
\ No newline at end of file