SparrowRenderer/material.cpp

26 lines
626 B
C++

#include "material.h"
#include "glew/glew.h"
#include "glassert.h"
#include "glm/glm.hpp"
GLuint Material::getLocation(std::string attribName)
{
glAssert(GLuint loc = glGetUniformLocation(getShader()->getProgramId(), attribName.c_str()));
return loc;
}
void Material::bindFloat(GLuint location, float val)
{
glAssert(glUniform1f(location, val));
}
void Material::bindMatrix(GLuint location, glm::mat4 mat)
{
glAssert(glUniformMatrix4fv(location, 1, GL_FALSE, glm::value_ptr(mat)));
}
void Material::bindVec3(GLuint location, glm::vec3 vec)
{
glAssert(glUniform3fv(location, 1, glm::value_ptr(vec)));
}