hello vulkan
Some checks failed
Build and Test verification / build (push) Failing after 25s
Build and Test verification / test (push) Has been skipped

This commit is contained in:
2026-05-09 20:22:51 -05:00
parent f72bd8c44f
commit fcdb09a142
7 changed files with 108 additions and 6 deletions

View File

@@ -25,9 +25,12 @@ FetchContent_Declare(
) )
FetchContent_MakeAvailable(sdl3) FetchContent_MakeAvailable(sdl3)
find_package(Vulkan REQUIRED)
# add_subdirectory() to nest CMakeLists # add_subdirectory() to nest CMakeLists
add_executable(maiden add_executable(maiden
src/Engine.cpp
src/App.cpp src/App.cpp
src/Window.cpp src/Window.cpp
src/main.cpp src/main.cpp
@@ -37,6 +40,7 @@ add_executable(maiden
add_executable(maiden_test add_executable(maiden_test
src/App.cpp src/App.cpp
src/Window.cpp src/Window.cpp
src/Engine.cpp
test/TestApp.cpp test/TestApp.cpp
) )
# i think the strat is to build all of the core app components into a single library # i think the strat is to build all of the core app components into a single library
@@ -49,6 +53,7 @@ target_include_directories(maiden PRIVATE
target_link_libraries(maiden PRIVATE target_link_libraries(maiden PRIVATE
SDL3::SDL3 SDL3::SDL3
Vulkan::Vulkan
) )
target_include_directories(maiden_test PRIVATE target_include_directories(maiden_test PRIVATE
@@ -64,6 +69,7 @@ target_link_libraries(maiden_test PRIVATE
GTest::gmock GTest::gmock
GTest::gmock_main GTest::gmock_main
SDL3::SDL3 SDL3::SDL3
Vulkan::Vulkan
) )
include(CTest) include(CTest)

View File

@@ -18,7 +18,30 @@ $ git clone --recurse-submodules https://git.vxbard.net/homeburger/maiden.git
# If you have already cloned the repository and you need its submodules: # If you have already cloned the repository and you need its submodules:
$ git submodule update --init --recursive $ git submodule update --init --recursive
``` ```
### Build
### Installation Prequisites
LunarG's Vulkan SDK is used for almost every Vulkan project, including this one.
Installation instructions here are for Ubuntu 24, further instructions can be found here: https://vulkan.lunarg.com/doc/sdk/1.4.341.1/linux/getting_started.html
```bash
$ cd ~/Downloads
$ wget "https://sdk.lunarg.com/sdk/download/1.4.341.1/linux/vulkansdk-linux-x86_64-1.4.341.1.tar.xz" # or the latest version on https://vulkan.lunarg.com/sdk/home
$ mkdir /opt/vulkan-sdk
$ cd /opt/vulkan-sdk
$ tar -xvf ~/Downloads/vulkansdk-linux-x86_64-1.4.341.1.tar.xz
$ sudo apt install libxcb-xinput0 libxcb-xinerama0 libxcb-cursor-dev # vulkan prerequeisites
```
Then to setup your current session:
```bash
$ source /opt/vulkan-sdk/1.4.341.1/setup-env.sh # or whichever version you have
```
Note: sourcing only affects your current shell session. Add to your .bashrc script if you wish for it to persist.
Verify your installation by using the the command:
```bash
$ vulkaninfo
```
### Build
This app uses CMake and C++20, so a compatible compiler (gcc8, clang9, msvc16) are necessary. This app uses CMake and C++20, so a compatible compiler (gcc8, clang9, msvc16) are necessary.
Most library prerequisites are handled within CMake. Any others that need to be manually installed will be described below as the project grows. Most library prerequisites are handled within CMake. Any others that need to be manually installed will be described below as the project grows.

View File

@@ -5,7 +5,7 @@
#include <chrono> #include <chrono>
#include <SDL3/SDL_events.h> #include <SDL3/SDL_events.h>
App::App(): window_(new Window()) { App::App(): window_(new Window()), engine_(new Engine(window_)) {
// smart pointers might be a good idea // smart pointers might be a good idea
// since app will be the top level owner we can use unique ptrs for almost everything // since app will be the top level owner we can use unique ptrs for almost everything
} }

View File

@@ -5,6 +5,7 @@
#include <cstdint> #include <cstdint>
#include "Window.hpp" #include "Window.hpp"
#include "Engine.hpp"
class App { class App {
@@ -17,6 +18,7 @@ public:
private: private:
Window* window_; Window* window_;
Engine* engine_;
bool rendering_ = true; bool rendering_ = true;

51
src/Engine.cpp Normal file
View File

@@ -0,0 +1,51 @@
#include "Engine.hpp"
#include "vulkan/vulkan.h"
#include <iostream>
Engine::Engine(Window* window): window_(window) {
// cleans up this constructor
init();
}
void Engine::init() {
VkApplicationInfo appInfo {
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
.pApplicationName = "maiden",
.apiVersion = VK_API_VERSION_1_4
};
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;
if(vkCreateInstance(&instanceCI, nullptr, &instance) == VK_SUCCESS) {
// TODO: need some kind of logger service
std::cout << "[" << __FUNCTION__ << ": " << __LINE__ << "] Vulkan instance successfully created." << std::endl;
} else {
std::cout << "[" << __FUNCTION__ << ": " << __LINE__ << "] Error creating Vulkan instance." << std::endl;
}
// next steps:
// device selection and setup
// queue creation
// vulkan memory allocator
// create vulkan surface
// attach surface to window
}
void Engine::draw() {
}

24
src/Engine.hpp Normal file
View File

@@ -0,0 +1,24 @@
#pragma once
#include "Window.hpp"
class Engine {
public:
Engine(Window* window);
~Engine() = default;
void init();
// draw is called every render iteration in that while loop
void draw();
private:
// might get rid of this
Window* window_;
};

View File

@@ -1,12 +1,8 @@
#include <iostream>
#include "App.hpp" #include "App.hpp"
int main(int argc, char** argv) { int main(int argc, char** argv) {
std::cout << "hi mom !" << std::endl;
// create app and run // create app and run
App app; App app;
app.run(); app.run();