diff --git a/.gitignore b/.gitignore index c4f0d1e..43ac2cb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.vscode/* build/* diff --git a/CMakeLists.txt b/CMakeLists.txt index f96ff36..272b052 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,12 @@ endif() set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}) #add_subdirectory(src) + +set(Vulkan_INCLUDE_DIR "${VULKAN_PATH}/Include") +set(Vulkan_LIBRARY "${VULKAN_PATH}/Lib/vulkan-1.lib") +find_package(Vulkan REQUIRED) + +# TODO: use SDL in the vulkanSDK if available set(SDL3_DIR "${SDL3_PATH}/cmake") find_package(SDL3 REQUIRED) @@ -42,4 +48,5 @@ endif() target_link_libraries(ouros PRIVATE SDL3::SDL3 + Vulkan::Vulkan ) diff --git a/README.md b/README.md index c29ee07..679e6c8 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,9 @@ $ git clone https://git.vxbard.net/homeburger/ouros.git --recursive ``` ### Configure and build project: ```bash -$ cmake -S . -B build -DSDL3_PATH="${SDL3_INSTALL_PATH}" # either set this variable or substitute it in +$ cmake -S . -B build \ + -VULKAN_PATH="${VULKAN_INSTALL_PATH}" \ # either set these variables or substitute them in + -DSDL3_PATH="${SDL3_INSTALL_PATH}" # optional, dont need if youre using the sdl in the vulkan sdk $ cmake --build build -j ``` ### Execute application: diff --git a/src/app/App.cpp b/src/app/App.cpp index 2021857..c705816 100644 --- a/src/app/App.cpp +++ b/src/app/App.cpp @@ -24,6 +24,8 @@ int App::run() { utils::debugPrint(__FUNCTION__, __LINE__, "Run app.", utils::DebugLevel::Trace); + engine_->exec(); + bool quit = false; while (!quit) { // app loop for as long as the window is open diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp new file mode 100644 index 0000000..99b4567 --- /dev/null +++ b/src/engine/Engine.cpp @@ -0,0 +1,44 @@ + +#include "Engine.hpp" + +#include "vulkan/vulkan.h" + +#include "utils/utils.hpp" + +Engine::Engine(Window* window): window_(window) { + + init(); + +} + +void Engine::init() { + +} + +void Engine::exec() { + + VkApplicationInfo appInfo { + .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO, + .pApplicationName = "How to Vulkan", + .apiVersion = VK_API_VERSION_1_3 + }; + + uint32_t instanceExtensionsCount = 0; + char const* const* instanceExtensions{ SDL_Vulkan_GetInstanceExtensions(&instanceExtensionsCount) }; + + VkInstanceCreateInfo instanceCI { + .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, + .pApplicationInfo = &appInfo, + .enabledExtensionCount = instanceExtensionsCount, + .ppEnabledExtensionNames = instanceExtensions, + }; + + VkInstance instance; + VkResult result = vkCreateInstance(&instanceCI, nullptr, &instance); + if(result == VK_SUCCESS) { + utils::debugPrint(__FUNCTION__, __LINE__, "Vulkan instance successfully created.", utils::DebugLevel::Info); + } else { + utils::debugPrint(__FUNCTION__, __LINE__, "Error creating Vulkan instance", utils::DebugLevel::Error); + } + +} diff --git a/src/engine/Engine.hpp b/src/engine/Engine.hpp new file mode 100644 index 0000000..8100683 --- /dev/null +++ b/src/engine/Engine.hpp @@ -0,0 +1,24 @@ + +#pragma once + +#include "app/Window.hpp" + +#define VK_USE_PLATFORM_WIN32_KHR 1 + +class Engine { + +public: + + Engine(Window* window); + ~Engine() = default; + + void exec(); + +private: + + void init(); + + // TODO: smart pointers probably would be smart + Window* window_; + +}; \ No newline at end of file