1#ifndef _RESOURCEMANAGER_HPP_
2#define _RESOURCEMANAGER_HPP_
14#define IMPLEMENT_RESOURCE_MANAGER \
15 std::function<std::any(BufferType, uint32_t, void*)> ResourceManager::BufferCreationFunc; \
16 std::function<std::any(const std::string&)> ResourceManager::ShaderCreateFunc;\
17 std::function<std::any(const std::string&)> ResourceManager::TextureCreateFunc; \
18 std::function<std::any(const void*, uint32_t, uint32_t, TextureFormat, uint32_t)> ResourceManager::TextureFromMemoryCreateFunc; \
19 std::function<std::any(const std::array<std::string, 6>&)> ResourceManager::CubemapTextureCreateFunc; \
20 std::function<std::any(const std::string&)> ResourceManager::CubemapPanoramaCreateFunc; \
21 std::mutex ResourceManager::threadManager;
24 namespace RenderEngine {
40 std::lock_guard<std::mutex> lock(threadManager);
41 BufferCreationFunc = [instance, method](
BufferType type, uint32_t size,
void* data) -> std::any {
42 return (instance->*method)(type, size, data);
49 std::lock_guard<std::mutex> lock(threadManager);
50 ShaderCreateFunc = [instance, method](
const std::string& path) -> std::any {
51 return (instance->*method)(path);
58 std::lock_guard<std::mutex> lock(threadManager);
59 TextureCreateFunc = [instance, method](
const std::string& path) -> std::any {
60 return (instance->*method)(path);
66 std::lock_guard<std::mutex> lock(threadManager);
67 TextureFromMemoryCreateFunc = [func](
const void* data, uint32_t w, uint32_t h,
TextureFormat fmt, uint32_t maxMip) -> std::any {
68 return func(data, w, h, fmt, maxMip);
75 std::lock_guard<std::mutex> lock(threadManager);
76 CubemapTextureCreateFunc = [instance, method](
const std::array<std::string, 6>& paths) -> std::any {
77 return (instance->*method)(paths);
84 std::lock_guard<std::mutex> lock(threadManager);
85 CubemapPanoramaCreateFunc = [instance, method](
const std::string& path) -> std::any {
86 return (instance->*method)(path);
105 static std::function<std::any(
BufferType, uint32_t,
void*)> BufferCreationFunc;
106 static std::function<std::any(
const std::string&)> ShaderCreateFunc;
107 static std::function<std::any(
const std::string&)> TextureCreateFunc;
108 static std::function<std::any(
const void*, uint32_t, uint32_t,
TextureFormat, uint32_t)> TextureFromMemoryCreateFunc;
109 static std::function<std::any(
const std::array<std::string, 6>&)> CubemapTextureCreateFunc;
110 static std::function<std::any(
const std::string&)> CubemapPanoramaCreateFunc;
113 static std::mutex threadManager;
Backend-agnostic GPU buffer: vertex, index, constant, or resource view target.
static void RegisterCreateCubemapTextureFromPanorama(T *instance, Texture *(T::*method)(const std::string &))
static Sleak::Texture * CreateCubemapTextureFromPanorama(const std::string &PanoramaPath)
Loads a cubemap from a single equirectangular panorama via the currently registered backend factory.
static void RegisterCreateCubemapTexture(T *instance, Texture *(T::*method)(const std::array< std::string, 6 > &))
static void RegisterCreateBuffer(T *instance, BufferBase *(T::*method)(BufferType, uint32_t, void *))
static Shader * CreateShader(const std::string &ShaderPath)
Compiles a shader via the currently registered backend factory.
static Sleak::Texture * CreateTexture(const std::string &TexturePath)
Loads a texture via the currently registered backend factory.
static void RegisterCreateShader(T *instance, Shader *(T::*method)(const std::string &))
static BufferBase * CreateBuffer(BufferType Type, uint32_t Size, void *Data)
Creates a buffer via the currently registered backend factory.
static void RegisterCreateTextureFromMemory(std::function< Texture *(const void *, uint32_t, uint32_t, TextureFormat, uint32_t)> func)
static Sleak::Texture * CreateTextureFromMemory(const void *data, uint32_t width, uint32_t height, TextureFormat format, uint32_t maxMipLevels=0)
Creates a texture from raw pixel data via the currently registered backend factory.
static void RegisterCreateTexture(T *instance, Texture *(T::*method)(const std::string &))
static Sleak::Texture * CreateCubemapTexture(const std::array< std::string, 6 > &FacePaths)
Loads a cubemap from six face image paths via the currently registered backend factory.
Backend-agnostic compiled shader program.
BufferType
GPU buffer usage kind, drives backend binding flags and layout.
ResourceType
Coarse kind tag for a graphics resource.
Root namespace for everything the engine exposes.