Materials are just structs

This commit is contained in:
Dane Johnson
2021-01-20 15:16:44 -06:00
parent 745f03d8a2
commit 0c9935a3c0
4 changed files with 11 additions and 19 deletions

View File

@@ -1,8 +1,6 @@
#include "Mesh.h"
SubMesh::SubMesh() {
material = new Material();
}
SubMesh::SubMesh() {}
SubMesh::SubMesh(VertexList vertices, IndexList indices) {
this->vertices = vertices;
@@ -35,8 +33,8 @@ void SubMesh::SetupSubMesh() {
}
void SubMesh::Draw(Shader *shader) {
shader->UpdateColor(material->usesColor, material->color);
shader->UpdateTex(material->usesTex, material->tex);
shader->UpdateColor(material.usesColor, material.color);
shader->UpdateTex(material.usesTex, material.tex);
glBindVertexArray(VAO);
glDrawElements(GL_TRIANGLES, indices.size() * 3, GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
@@ -56,7 +54,7 @@ void Mesh::SetupMesh() {
}
}
void Mesh::SetMaterial(int submesh, Material *material) {
void Mesh::SetMaterial(int submesh, Material material) {
submeshes[submesh]->material = material;
}

View File

@@ -24,7 +24,7 @@ public:
SubMesh(VertexList vertices, IndexList indices);
VertexList vertices;
IndexList indices;
Material *material;
Material material;
void SetupSubMesh();
void Draw(Shader *shader);
private:
@@ -37,7 +37,7 @@ class Mesh : public Spatial {
public:
Mesh();
~Mesh();
void SetMaterial(int submesh, Material *material);
void SetMaterial(int submesh, Material material);
static Mesh *FromFile(const char *filename);
virtual bool IsDrawable() const {return true;}
virtual void Draw(Shader *shader);