Fixed the textures problem but it's still not amazing.

This commit is contained in:
Zed A. Shaw 2026-08-27 14:29:52 -04:00
parent 2ce7375233
commit d03afb31e1
8 changed files with 11 additions and 25 deletions

View file

@ -2,22 +2,25 @@
#include "dbc.hpp"
void Mesh::draw(Shader &shader) {
// CAN WE DO THIS LESS OFTEN OUTSIDE DRAWING?
apply_textures(shader);
glBindVertexArray(VAO);
glDrawElements(GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
glActiveTexture(GL_TEXTURE0);
}
void Mesh::connect_shader(const Shader& shader) {
void Mesh::apply_textures(const Shader& shader) {
for(unsigned int i = 0; i < textures.size(); i++) {
Texture& texture = textures[i];
texture.uniform_id = glGetUniformLocation(shader.ID, texture.target.c_str());
glActiveTexture(GL_TEXTURE0 + i);
// move this to setup_mesh
glUniform1i(texture.uniform_id, i);
glBindTexture(GL_TEXTURE_2D, texture.id);
texture.uniform_id = glGetUniformLocation(shader.ID, texture.target.c_str());
}
}