5 #include <config/ConEntry.h>
6 #include <math/Matrix.h>
11 this->handle = Renderer::createMesh(this->vertices, this->indices, MeshDrawMode::STATIC);
12 this->initialized =
true;
16 if (!this->initialized)
18 Renderer::updateMesh(&this->handle, this->vertices, this->indices, this->drawMode);
21 void MeshData::render(glm::mat4 model, MeshCullType cullType ) {
22 if (!this->initialized)
25 this->material->use();
26 if (this->material->getShader()->usesModelMatrix())
27 this->material->getShader()->setUniform(
"m", model);
29 Renderer::drawMesh(this->handle, this->depthFunction, cullType);
32 MeshData::~MeshData() {
33 if (this->initialized) {
34 Renderer::destroyMesh(this->handle);
39 return this->material;
43 this->material = std::move(newMaterial);
46 MeshDepthFunction MeshData::getDepthFunction()
const {
47 return this->depthFunction;
50 void MeshData::setDepthFunction(MeshDepthFunction
function) {
51 this->depthFunction =
function;
54 std::vector<byte> MeshData::getMeshData(
const std::string& meshLoader)
const {
55 return IMeshLoader::getMeshLoader(meshLoader)->createMesh(this->vertices, this->indices);
58 void MeshData::appendMeshData(
const std::string& loader,
const std::string& identifier) {
59 IMeshLoader::getMeshLoader(loader)->loadMesh(identifier, this->vertices, this->indices);
63 this->vertices.clear();
64 this->indices.clear();
void updateMeshData()
Updates the vertex buffers with the current mesh data.
void setupForRendering()
Establishes the vertex buffers and copies the current mesh data into them.
void clearMeshData()
Does not call updateMeshData().