ECS rendering

This commit is contained in:
2025-08-22 16:15:42 -05:00
parent 94ad64675d
commit f9385ed233
17 changed files with 161 additions and 215 deletions

View File

@@ -9,23 +9,35 @@
#include "scene/node.h"
#include "display/camera.h"
#include "display/display.h"
#include "display/mesh/meshrenderer.h"
ecsid_t sceneTestAdd(void) {
ecsid_t id = ecsEntityAdd();
mesh_t mesh;
meshvertex_t triangle[3] = {
{{255, 0, 0, 255}, {0.0f, 0.0f}, {1.0f, 0.0f}}, // Vertex 1
{{0, 255, 0, 255}, {1.0f, 0.0f}, {-1.0f, 0.0f}}, // Vertex 2
{{0, 0, 255, 255}, {0.5f, 1.0f}, {0, 2.0f}} // Vertex 3
};
void sceneTestAdd(void) {
meshInit(&mesh, MESH_PRIMITIVE_TRIANGLES, 3, triangle);
// Initialize the entity with a camera component
ecsid_t camera = ecsEntityAdd();
nodeChildAdd(id, camera);
node_t *node = nodeAdd(camera);
camera_t *camData = cameraAdd(camera);
camData->type = CAMERA_TYPE_ORTHOGRAPHIC;
camData->orthographic.left = 0.0f;
camData->orthographic.right = 1.0f;
camData->orthographic.top = 0.0f;
camData->orthographic.bottom = 1.0f;
camData->nearClip = -1.0f;
camData->farClip = 1.0f;
mat4 lookAt;
glm_lookat(
(vec3){ 3.0f, 3.0f, 3.0f },
(vec3){ 0.0f, 0.0f, 0.0f },
(vec3){ 0.0f, 1.0f, 0.0f },
lookAt
);
nodeMatrixSet(camera, lookAt);
// Optionally, you can set other properties or components here
return id;
// Test cube
ecsid_t cube = ecsEntityAdd();
node = nodeAdd(cube);
meshrenderer_t *renderer = meshRendererAdd(cube);
renderer->mesh = &mesh;
}