Models all tested and refactored so that the draw() call doesn't do a bunch of irrelevant shit.
This commit is contained in:
parent
2431cf8c97
commit
47bd233722
6 changed files with 102 additions and 70 deletions
|
|
@ -10,33 +10,63 @@
|
|||
#include <vector>
|
||||
|
||||
struct Vertex {
|
||||
glm::vec3 Position;
|
||||
glm::vec3 Normal;
|
||||
glm::vec2 TexCoords;
|
||||
glm::vec3 position;
|
||||
glm::vec3 normal;
|
||||
glm::vec2 tex_coords;
|
||||
};
|
||||
|
||||
struct TextureCounts {
|
||||
unsigned int diffuseNr = 1;
|
||||
unsigned int specularNr = 1;
|
||||
unsigned int normalNr = 1;
|
||||
unsigned int heightNr = 1;
|
||||
};
|
||||
|
||||
struct Texture {
|
||||
unsigned int id;
|
||||
std::string type;
|
||||
std::string path;
|
||||
std::string target;
|
||||
int uniform_id=-1;
|
||||
|
||||
Texture(unsigned int id, const std::string& type, const std::string& path, TextureCounts& count) :
|
||||
id(id), type(type)
|
||||
{
|
||||
unsigned int number = 0;
|
||||
|
||||
if(type == "texture_diffuse") {
|
||||
number = count.diffuseNr++;
|
||||
} else if(type == "texture_specular") {
|
||||
number = count.specularNr++;
|
||||
} else if(type == "texture_normal") {
|
||||
number = count.normalNr++;
|
||||
} else if(type == "texture_height") {
|
||||
number = count.heightNr++;
|
||||
} else {
|
||||
dbc::sentinel($F("Invalid texture type={} for file={}", type, path));
|
||||
}
|
||||
|
||||
target = std::format("{}{}", type, number);
|
||||
}
|
||||
};
|
||||
|
||||
struct Mesh {
|
||||
std::vector<Vertex> vertices;
|
||||
std::vector<unsigned int> indices;
|
||||
std::vector<Texture> textures;
|
||||
unsigned int VAO;
|
||||
unsigned int VBO;
|
||||
unsigned int EBO;
|
||||
unsigned int VAO = 0;
|
||||
unsigned int VBO = 0;
|
||||
unsigned int EBO = 0;
|
||||
|
||||
Mesh(std::vector<Vertex> vertices, std::vector<unsigned int> indices, std::vector<Texture> textures) :
|
||||
Mesh(std::vector<Vertex>& vertices, std::vector<unsigned int>& indices, std::vector<Texture>& textures) :
|
||||
vertices(vertices),
|
||||
indices(indices),
|
||||
textures(textures)
|
||||
{
|
||||
setupMesh();
|
||||
setup_mesh();
|
||||
}
|
||||
|
||||
void Draw(Shader &shader);
|
||||
void setupMesh();
|
||||
void draw(Shader &shader);
|
||||
void setup_mesh();
|
||||
void connect_shader(const Shader& shader);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue