10#define GLFW_INCLUDE_VULKAN
11#include <GLFW/glfw3.h>
14#define GLFW_EXPOSE_NATIVE_WIN32
15#include "GLFW/glfw3native.h"
18#define GLM_FORCE_RADIANS
19#define GLM_FORCE_DEPTH_ZERO_TO_ONE
20#define GLM_ENABLE_EXPERIMENTAL
22#include <glm/gtc/matrix_access.hpp>
23#include <glm/gtc/matrix_transform.hpp>
24#include <glm/gtc/type_ptr.hpp>
25#include <glm/gtx/hash.hpp>
26#include <glm/gtx/rotate_vector.hpp>
28#include <imgui/imgui.h>
29#include <imgui/imgui_impl_glfw.h>
30#include <imgui/imgui_impl_vulkan.h>
32#include <stb/stb_image.h>
33#include <stb/stb_image_write.h>
35#ifdef MANDRILL_USE_OPENVDB
36#include <openvdb/openvdb.h>
42#include <condition_variable>
52#include <source_location>
55#include <unordered_map>
60#define MANDRILL_NAME "Mandrill"
63#ifndef MANDRILL_VERSION_MAJOR
64#error "Missing major version number"
66#ifndef MANDRILL_VERSION_MINOR
67#error "Missing minor version number"
69#ifndef MANDRILL_VERSION_PATCH
70#error "Missing patch version number"
74#define MANDRILL_PLATFORM_WINDOWS 1
75#define MANDRILL_PLATFORM_LINUX 2
77#ifndef MANDRILL_PLATFORM
79#define MANDRILL_PLATFORM MANDRILL_PLATFORM_WINDOWS
80#elif defined(__linux__)
81#define MANDRILL_PLATFORM MANDRILL_PLATFORM_LINUX
83#error "Unsupported target platform"
87#define MANDRILL_WINDOWS (MANDRILL_PLATFORM == MANDRILL_PLATFORM_WINDOWS)
88#define MANDRILL_LINUX (MANDRILL_PLATFORM == MANDRILL_PLATFORM_LINUX)
92#define MANDRILL_API_EXPORT __declspec(dllexport)
93#define MANDRILL_API_IMPORT __declspec(dllimport)
95#define MANDRILL_API_EXPORT __attribute__((visibility("default")))
96#define MANDRILL_API_IMPORT
100#define MANDRILL_API MANDRILL_API_EXPORT
102#define MANDRILL_API MANDRILL_API_IMPORT
106#define MANDRILL_NON_COPYABLE(x) \
107 MANDRILL_API x() = delete; \
108 MANDRILL_API x(const x&) = delete; \
109 MANDRILL_API x& operator=(const x&) = delete;
115 template <
typename T>
using ptr = std::shared_ptr<T>;
118 template <
typename T,
typename... Args>
static inline ptr<T> make_ptr(Args&&... args)
120 return std::make_shared<T>(std::forward<Args>(args)...);
123 template <
typename T>
124 concept Sizable =
requires(T t) {
125 { t.size() } -> std::convertible_to<std::size_t>;
129 template <Sizable T>
static inline uint32_t count(
const T& t)
131 return static_cast<uint32_t
>(t.size());
134 static inline std::filesystem::path GetExecutablePath()
136 std::filesystem::path path;
138 TCHAR szFile[260] = {0};
139 GetModuleFileNameA(NULL, szFile, 260);
140 path = std::filesystem::path(szFile);
142 path = std::filesystem::canonical(
"/proc/self/exe");
144 return path.remove_filename();
148#define LPCSTR const char*
157 static inline std::string OpenFile(GLFWwindow* pWindow, LPCSTR filter)
161 TCHAR szFile[260] = {0};
163 ZeroMemory(&ofn,
sizeof(ofn));
164 ofn.lStructSize =
sizeof(ofn);
165 ofn.hwndOwner = glfwGetWin32Window(pWindow);
166 ofn.lpstrFile = szFile;
167 ofn.nMaxFile =
sizeof(szFile);
168 ofn.lpstrFilter = filter;
169 ofn.nFilterIndex = 1;
170 ofn.lpstrFileTitle = NULL;
171 ofn.nMaxFileTitle = 0;
172 ofn.lpstrInitialDir = NULL;
173 ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
175 if (GetOpenFileNameA(&ofn)) {
176 return std::string(ofn.lpstrFile);
181 FILE* f = popen(
"zenity --file-selection --modal --title=\"Select file\"",
"r");
184 fgets(filename,
sizeof(filename), f);
185 filename[std::strcspn(filename,
"\n")] = 0;
187 return std::string(filename);