hello vulkan
This commit is contained in:
@@ -25,9 +25,12 @@ FetchContent_Declare(
|
||||
)
|
||||
FetchContent_MakeAvailable(sdl3)
|
||||
|
||||
find_package(Vulkan REQUIRED)
|
||||
|
||||
# add_subdirectory() to nest CMakeLists
|
||||
|
||||
add_executable(maiden
|
||||
src/Engine.cpp
|
||||
src/App.cpp
|
||||
src/Window.cpp
|
||||
src/main.cpp
|
||||
@@ -37,6 +40,7 @@ add_executable(maiden
|
||||
add_executable(maiden_test
|
||||
src/App.cpp
|
||||
src/Window.cpp
|
||||
src/Engine.cpp
|
||||
test/TestApp.cpp
|
||||
)
|
||||
# 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
|
||||
SDL3::SDL3
|
||||
Vulkan::Vulkan
|
||||
)
|
||||
|
||||
target_include_directories(maiden_test PRIVATE
|
||||
@@ -64,6 +69,7 @@ target_link_libraries(maiden_test PRIVATE
|
||||
GTest::gmock
|
||||
GTest::gmock_main
|
||||
SDL3::SDL3
|
||||
Vulkan::Vulkan
|
||||
)
|
||||
|
||||
include(CTest)
|
||||
|
||||
25
README.md
25
README.md
@@ -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:
|
||||
$ 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.
|
||||
|
||||
Most library prerequisites are handled within CMake. Any others that need to be manually installed will be described below as the project grows.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <chrono>
|
||||
#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
|
||||
// since app will be the top level owner we can use unique ptrs for almost everything
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include "Window.hpp"
|
||||
#include "Engine.hpp"
|
||||
|
||||
class App {
|
||||
|
||||
@@ -17,6 +18,7 @@ public:
|
||||
private:
|
||||
|
||||
Window* window_;
|
||||
Engine* engine_;
|
||||
|
||||
bool rendering_ = true;
|
||||
|
||||
|
||||
51
src/Engine.cpp
Normal file
51
src/Engine.cpp
Normal 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
24
src/Engine.hpp
Normal 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_;
|
||||
|
||||
};
|
||||
@@ -1,12 +1,8 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "App.hpp"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
std::cout << "hi mom !" << std::endl;
|
||||
|
||||
// create app and run
|
||||
App app;
|
||||
app.run();
|
||||
|
||||
Reference in New Issue
Block a user