summaryrefslogtreecommitdiff
path: root/src/gpu/texture_manager.h
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-01 10:51:15 +0100
committerskal <pascal.massimino@gmail.com>2026-02-01 10:51:15 +0100
commit8bdc4754647c9c6691130fa91d51fee93c5fc88f (patch)
tree2cfd7f72a21541c488ea48629eef47a6774fc2c4 /src/gpu/texture_manager.h
parent7905abd9f7ad35231289e729b42e3ad57a943ff5 (diff)
feat: Implement 3D system and procedural texture manager
- Extended mini_math.h with mat4 multiplication and affine transforms. - Implemented TextureManager for runtime procedural texture generation and GPU upload. - Added 3D system components: Camera, Object, Scene, and Renderer3D. - Created test_3d_render mini-demo for interactive 3D verification. - Fixed WebGPU validation errors regarding depthSlice and unimplemented WaitAny.
Diffstat (limited to 'src/gpu/texture_manager.h')
-rw-r--r--src/gpu/texture_manager.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/gpu/texture_manager.h b/src/gpu/texture_manager.h
new file mode 100644
index 0000000..3faf74c
--- /dev/null
+++ b/src/gpu/texture_manager.h
@@ -0,0 +1,48 @@
+// 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 <map>
+#include <string>
+#include <vector>
+
+#if defined(DEMO_CROSS_COMPILE_WIN32)
+#include <webgpu/webgpu.h>
+#else
+#include <webgpu.h>
+#endif
+
+struct ProceduralTextureDef {
+ int width;
+ int height;
+ void (*gen_func)(uint8_t*, int, int, const float*, int);
+ std::vector<float> 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);
+
+ // 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<std::string, GpuTexture> textures_;
+};