fix sdl3 linking + comments
This commit is contained in:
@@ -20,8 +20,7 @@ set(Vulkan_INCLUDE_DIR "${VULKAN_PATH}/Include")
|
|||||||
set(Vulkan_LIBRARY "${VULKAN_PATH}/Lib/vulkan-1.lib")
|
set(Vulkan_LIBRARY "${VULKAN_PATH}/Lib/vulkan-1.lib")
|
||||||
find_package(Vulkan REQUIRED)
|
find_package(Vulkan REQUIRED)
|
||||||
|
|
||||||
# TODO: use SDL in the vulkanSDK if available
|
set(SDL3_DIR "${VULKAN_PATH}/cmake")
|
||||||
set(SDL3_DIR "${SDL3_PATH}/cmake")
|
|
||||||
find_package(SDL3 REQUIRED)
|
find_package(SDL3 REQUIRED)
|
||||||
|
|
||||||
# TODO: cascade cmakelists.txt
|
# TODO: cascade cmakelists.txt
|
||||||
@@ -38,7 +37,7 @@ target_include_directories(ouros PRIVATE
|
|||||||
)
|
)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(SDL3_DLL "${SDL3_PATH}/lib/x64/SDL3.dll") # assuming youre not arm or 32 bit
|
set(SDL3_DLL "${VULKAN_PATH}/Bin/SDL3.dll")
|
||||||
add_custom_command(TARGET ouros POST_BUILD
|
add_custom_command(TARGET ouros POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
"${SDL3_DLL}"
|
"${SDL3_DLL}"
|
||||||
|
|||||||
11
README.md
11
README.md
@@ -43,10 +43,14 @@ Below is beyond Sascha's guide, but available elsewhere on his github. These are
|
|||||||
- CMake (im using 4.0.0)
|
- CMake (im using 4.0.0)
|
||||||
- C++20 compatible compiler (I use g++12 or MSVC++17) (probably works with mingw but I haven't tested it myself)
|
- C++20 compatible compiler (I use g++12 or MSVC++17) (probably works with mingw but I haven't tested it myself)
|
||||||
- Vulkan compatible gpu drivers (tested with an RTX3070 and an R9700)
|
- Vulkan compatible gpu drivers (tested with an RTX3070 and an R9700)
|
||||||
- Vulkan SDK (https://vulkan.lunarg.com/sdk/home) <- the installer provides the option to install SDL and VOC as well as verifies GPU drivers
|
- Vulkan SDK (https://vulkan.lunarg.com/sdk/home)
|
||||||
- SDL3 (im using version 3.4.4)
|
- SDL3*
|
||||||
|
- VOC*
|
||||||
|
- GLM*
|
||||||
- Will add more as the project grows
|
- Will add more as the project grows
|
||||||
|
|
||||||
|
*packaged with the Vulkan SDK
|
||||||
|
|
||||||
### Clone respository:
|
### Clone respository:
|
||||||
```bash
|
```bash
|
||||||
$ git clone https://git.vxbard.net/homeburger/ouros.git --recursive
|
$ git clone https://git.vxbard.net/homeburger/ouros.git --recursive
|
||||||
@@ -54,8 +58,7 @@ $ git clone https://git.vxbard.net/homeburger/ouros.git --recursive
|
|||||||
### Configure and build project:
|
### Configure and build project:
|
||||||
```bash
|
```bash
|
||||||
$ cmake -S . -B build \
|
$ cmake -S . -B build \
|
||||||
-VULKAN_PATH="${VULKAN_INSTALL_PATH}" \ # either set these variables or substitute them in
|
-DVULKAN_PATH="${VULKAN_INSTALL_PATH}" # either set this variable or substitute it in
|
||||||
-DSDL3_PATH="${SDL3_INSTALL_PATH}" # optional, dont need if youre using the sdl in the vulkan sdk
|
|
||||||
$ cmake --build build -j
|
$ cmake --build build -j
|
||||||
```
|
```
|
||||||
### Execute application:
|
### Execute application:
|
||||||
|
|||||||
@@ -24,12 +24,10 @@ int App::run() {
|
|||||||
|
|
||||||
utils::debugPrint(__FUNCTION__, __LINE__, "Run app.", utils::DebugLevel::Trace);
|
utils::debugPrint(__FUNCTION__, __LINE__, "Run app.", utils::DebugLevel::Trace);
|
||||||
|
|
||||||
engine_->exec();
|
|
||||||
|
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
while (!quit) {
|
while (!quit) {
|
||||||
// app loop for as long as the window is open
|
// app loop for as long as the window is open
|
||||||
// other threads might be able to change quit to true to auto close
|
// other threads might be able to change quit to true to auto close in the future
|
||||||
|
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while(SDL_PollEvent(&event)) { // TODO: pass event handling to window
|
while(SDL_PollEvent(&event)) { // TODO: pass event handling to window
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public:
|
|||||||
App();
|
App();
|
||||||
~App() = default;
|
~App() = default;
|
||||||
|
|
||||||
// excecute, called from main()
|
// excecute, called from main(). returns after window closes
|
||||||
int run();
|
int run();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ Window::~Window() {
|
|||||||
|
|
||||||
int Window::init() {
|
int Window::init() {
|
||||||
|
|
||||||
sdlWindow_ = SDL_CreateWindow("How to Vulkan", 1280u, 720u, SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE);
|
sdlWindow_ = SDL_CreateWindow("Ouros: Vulkan", 1280u, 720u, SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE);
|
||||||
|
|
||||||
return (sdlWindow_ == nullptr);
|
return (sdlWindow_ == nullptr);
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,12 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
// launches window
|
||||||
int init();
|
int init();
|
||||||
|
|
||||||
|
// this window class will eventually hold mouse, keyboard, audio, etc. interfaces, like an SDL3 hub
|
||||||
|
// app will be able to attach callbacks for mouse and keyboard events
|
||||||
|
|
||||||
SDL_Window* sdlWindow_;
|
SDL_Window* sdlWindow_;
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -13,10 +13,6 @@ Engine::Engine(Window* window): window_(window) {
|
|||||||
|
|
||||||
void Engine::init() {
|
void Engine::init() {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Engine::exec() {
|
|
||||||
|
|
||||||
VkApplicationInfo appInfo {
|
VkApplicationInfo appInfo {
|
||||||
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
||||||
.pApplicationName = "How to Vulkan",
|
.pApplicationName = "How to Vulkan",
|
||||||
@@ -41,3 +37,7 @@ void Engine::exec() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Engine::process() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,12 +12,14 @@ public:
|
|||||||
Engine(Window* window);
|
Engine(Window* window);
|
||||||
~Engine() = default;
|
~Engine() = default;
|
||||||
|
|
||||||
void exec();
|
void init();
|
||||||
|
|
||||||
|
// process is called every render iteration in that while loop
|
||||||
|
void process();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// might get rid of this
|
// might get rid of this
|
||||||
void init();
|
|
||||||
|
|
||||||
// TODO: smart pointers probably would be smart
|
// TODO: smart pointers probably would be smart
|
||||||
Window* window_;
|
Window* window_;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ int main(int argc, char *argv[]) {
|
|||||||
// maybe do some exceptions here
|
// maybe do some exceptions here
|
||||||
App app = App();
|
App app = App();
|
||||||
|
|
||||||
|
// executes for as long as the window is open
|
||||||
return app.run();
|
return app.run();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,10 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// TODO: might move a lot of this into a debug.h file
|
// TODO: might move a lot of this into a debug.hpp file
|
||||||
// TODO: logging ? but i dont care enough
|
// TODO: logging ? but i dont care enough
|
||||||
|
|
||||||
|
// do i classify this up? global static functions kinda scare me but i mean otrherwise itll be a global singleton so idk
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
enum DebugLevel : size_t {
|
enum DebugLevel : size_t {
|
||||||
@@ -31,10 +32,11 @@ namespace utils {
|
|||||||
"Extra1",
|
"Extra1",
|
||||||
"Extra2"
|
"Extra2"
|
||||||
};
|
};
|
||||||
// the idea is to have a debug bitmask, maybe 8 bits wide, where the bits can be set via compiler flags
|
|
||||||
|
|
||||||
|
// stores the input that determines which debug statements to filter
|
||||||
inline uint8_t debugMask;
|
inline uint8_t debugMask;
|
||||||
|
|
||||||
|
// print to standard output in a normalized format, includes the trace and debug level
|
||||||
static void debugPrint(const char* function, int line, std::string message, size_t debugLevel) {
|
static void debugPrint(const char* function, int line, std::string message, size_t debugLevel) {
|
||||||
|
|
||||||
if(!((debugMask >> debugLevel) & 1)) return; // then ignore this debug level
|
if(!((debugMask >> debugLevel) & 1)) return; // then ignore this debug level
|
||||||
@@ -45,14 +47,16 @@ namespace utils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// process the input from the executable (0bxxxxxxxx)
|
||||||
static void parseDebugMaskString(std::string& debugMaskString) {
|
static void parseDebugMaskString(std::string& debugMaskString) {
|
||||||
std::string value = debugMaskString;
|
std::string value = debugMaskString;
|
||||||
if(value.rfind("0b", 0) == 0) {
|
if(value.rfind("0b", 0) == 0) { // may allow other inputs in the future, this is just a binary byte
|
||||||
value = value.substr(2); // strip the binary literal identifier
|
value = value.substr(2); // strip the binary literal identifier
|
||||||
|
debugMask = static_cast<uint8_t>(std::stoul(value, nullptr, 2)); // interpret a string as a uint
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Unsupported debug key." << std::endl;
|
std::cout << "Unsupported debug key." << std::endl;
|
||||||
|
debugMask = 0; // disable debug statements
|
||||||
}
|
}
|
||||||
debugMask = static_cast<uint8_t>(std::stoul(value, nullptr, 2)); // interpret a string as a uint
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user