// This file is part of the 64k demo project. // It defines the TextureManager for procedural assets. // Handles generation and GPU upload of procedural textures. #pragma once #include "gpu/gpu.h" #include #include #include struct ProceduralTextureDef { int width; int height; bool (*gen_func)(uint8_t*, int, int, const float*, int); std::vector params; }; struct GpuTexture { WGPUTexture texture; WGPUTextureView view; int width; int height; }; class TextureManager { public: void init(WGPUDevice device, WGPUQueue queue); void shutdown(); // Registers and generates a texture immediately void create_procedural_texture(const std::string& name, const ProceduralTextureDef& def); // Creates a texture from existing data (RGBA8) void create_texture(const std::string& name, int width, int height, const uint8_t* data); // Retrieves a texture view by name (returns nullptr if not found) WGPUTextureView get_texture_view(const std::string& name); private: WGPUDevice device_; WGPUQueue queue_; std::map textures_; };