asset_manager concept

This commit is contained in:
2026-09-09 11:36:07 -07:00
parent 9aef3f57fc
commit 4190ff847b
14 changed files with 525 additions and 12 deletions
+11
View File
@@ -10,6 +10,10 @@
#include <string>
#include <vector>
#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/glm.hpp>
namespace sophia {
class Application {
@@ -40,6 +44,13 @@ class Application {
Camera2D camera;
std::vector<std::string> args;
// Creates a mesh that persists across frames, for callers that want to
// draw the same geometry many times with different transforms (e.g.
// instancing) instead of resubmitting vertices every frame via Canvas.
MeshHandle createMesh(std::vector<CanvasVertex> vertices,
std::vector<u32> indices);
void drawMesh(MeshHandle handle, const glm::mat4& transform);
private:
friend class Canvas;
+35
View File
@@ -0,0 +1,35 @@
#pragma once
#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/quaternion.hpp>
#include <string>
namespace sophia {
struct TagComponent {
std::string tag; // entt::hashed_string ?
};
struct TransformComponent {
glm::vec3 position{0.f, 0.f, 0.f};
glm::quat rotation{1.f, 0.f, 0.f, 0.f};
glm::vec3 scale{1.f, 1.f, 1.f};
glm::mat4 mat4() const {
return glm::translate(glm::mat4{1.f}, position) * glm::mat4_cast(rotation) *
glm::scale(glm::mat4{1.f}, scale);
}
glm::mat3 normalMatrix() const {
return glm::mat3{glm::transpose(glm::inverse(mat4()))};
}
};
struct MeshComponent {
MeshHandle handle;
};
} // namespace sophia
+2
View File
@@ -17,4 +17,6 @@ using s64 = int64_t;
using f32 = float;
using f64 = double;
using MeshHandle = u32;
} // namespace sophia