SparrowRenderer/entity.cpp

19 lines
615 B
C++

#include "entity.h"
#include "shader.h"
#include <glm/glm.hpp>
#include "material.h"
#include "mesh.h"
void Entity::draw(const glm::mat4 viewMatrix, const glm::mat4 projectionMatrix)
{
glm::mat4 modelViewMatrix = viewMatrix * modelMatrix;
glm::mat4 mvp = projectionMatrix * modelViewMatrix;
Shader* shader = mat->getShader();
shader->bind();
mat->bindAttributes();
shader->bindMatrix(shader->getLocation("viewMatrix"), viewMatrix);
shader->bindMatrix(shader->getLocation("modelViewMatrix"), modelViewMatrix);
shader->bindMatrix(shader->getLocation("MVP"), mvp);
mesh->draw();
}