png支持

This commit is contained in:
ArchZer0
2026-08-17 10:26:27 +08:00
parent 07aeced2e4
commit 63d97f058a
25 changed files with 893 additions and 261 deletions
+7 -6
View File
@@ -9,17 +9,18 @@
namespace boundard {
// 渲染组件:描述 Actor 的几何形状、颜色和纹理占位
// 渲染组件:描述 Actor 的几何形状、颜色和可选 PNG 纹理。
class Mesh {
public:
struct Vertex {
std::array<float, 2> position;
std::array<float, 4> color;
std::array<float, 2> uv;
};
std::vector<Vertex> vertices;
std::vector<uint32_t> indices;
std::string texture; // 纹理路径占位,暂未采样
std::string texture; // PNG 纹理路径;为空时使用白色纹理。
std::array<float, 4> color() const {
std::lock_guard<std::mutex> lock(*color_mutex_);
@@ -34,10 +35,10 @@ class Mesh {
static Mesh quad() {
Mesh mesh;
mesh.vertices = {
{{-1.0F, -1.0F}, {1.0F, 1.0F, 1.0F, 1.0F}},
{{1.0F, -1.0F}, {1.0F, 1.0F, 1.0F, 1.0F}},
{{1.0F, 1.0F}, {1.0F, 1.0F, 1.0F, 1.0F}},
{{-1.0F, 1.0F}, {1.0F, 1.0F, 1.0F, 1.0F}},
{{-1.0F, -1.0F}, {1.0F, 1.0F, 1.0F, 1.0F}, {0.0F, 0.0F}},
{{1.0F, -1.0F}, {1.0F, 1.0F, 1.0F, 1.0F}, {1.0F, 0.0F}},
{{1.0F, 1.0F}, {1.0F, 1.0F, 1.0F, 1.0F}, {1.0F, 1.0F}},
{{-1.0F, 1.0F}, {1.0F, 1.0F, 1.0F, 1.0F}, {0.0F, 1.0F}},
};
mesh.indices = {0, 1, 2, 2, 3, 0};
return mesh;