mirror of
https://github.com/Relintai/sfw.git
synced 2024-12-20 21:06:49 +01:00
Added text_2d.h and .cpp.
This commit is contained in:
parent
5dd2c168b6
commit
27e35c6553
37
sfw/render_objects/text_2d.cpp
Normal file
37
sfw/render_objects/text_2d.cpp
Normal 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();
|
||||
}
|
26
sfw/render_objects/text_2d.h
Normal file
26
sfw/render_objects/text_2d.h
Normal 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
|
Loading…
Reference in New Issue
Block a user