Added text_2d.h and .cpp.

This commit is contained in:
Relintai 2024-01-04 17:31:06 +01:00
parent 5dd2c168b6
commit 27e35c6553
2 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,37 @@
#include "render_objects/mesh_instance_2d.h"
#include "render_objects/camera_2d.h"
void MeshInstance2D::render() {
if (!mesh) {
return;
}
Transform2D mat_orig = Camera2D::current_camera->get_model_view_matrix();
Camera2D::current_camera->set_model_view_matrix(mat_orig * transform);
if (material) {
material->bind();
}
mesh->render();
for (int i = 0; i < children.size(); ++i) {
MeshInstance2D *c = children[i];
if (c) {
c->render();
}
}
Camera2D::current_camera->set_model_view_matrix(mat_orig);
}
MeshInstance2D::MeshInstance2D() {
material = NULL;
mesh = NULL;
}
MeshInstance2D::~MeshInstance2D() {
children.clear();
}

View File

@ -0,0 +1,26 @@
#ifndef MESH_INSTACE_2D_H
#define MESH_INSTACE_2D_H
#include "core/vector.h"
#include "render_core/material.h"
#include "render_core/mesh.h"
#include "core/transform.h"
class MeshInstance2D {
public:
void render();
MeshInstance2D();
~MeshInstance2D();
Material *material;
Mesh *mesh;
Transform2D transform;
Vector<MeshInstance2D *> children;
};
#endif // MESH_INSTACE_H