#include "material.h"

Material::Material(vec4 ambient, vec4 difus, vec4 especular, float s)
{

    component_ambient = ambient;
    component_difusa = difus;
    component_especular = especular;

    shininess = s;

}
Material::Material(){

}


void Material::toGPU(QGLShaderProgram *program,
                     const char * ambient,
                     const char * difus,
                     const char * especular,
                     const char * shininessCoef)
{

    struct {
        GLuint comp_ambient;
        GLuint comp_difusa;
        GLuint comp_especular;

        float coef;

    } material;

    material.comp_ambient = program->uniformLocation(ambient);
    material.comp_difusa = program->uniformLocation(difus);
    material.comp_especular = program->uniformLocation(especular);
    material.coef = program->uniformLocation(shininessCoef);

    glUniform4fv(material.comp_ambient, 1,component_ambient);
    glUniform4fv(material.comp_difusa, 1,component_difusa);
    glUniform4fv(material.comp_especular,1, component_especular);
    glUniform1f(material.coef, shininess);

}

vec4 Material::getAmbient()
{
    return component_ambient;
}

vec4 Material::getDifusa()
{
    return component_difusa;
}

vec4 Material::getEspecular()
{
    return component_especular;
}

float Material::getShininess()
{
    return shininess;
}

