#include "phongmaterial.h" #include "texture.h" #include "phongmodule.h" #define TEX_ID 0 void PhongMaterial::updateShader() { shader = PhongModule::getShader(diffuse_texture == NULL ? PhongModule::PHONG_COLOR : PhongModule::PHONG_TEXTURE); } void PhongMaterial::bindAttributes() { shader->bind(); shader->bindVec3(shader->getLocation("materialKd"), kd); shader->bindVec3(shader->getLocation("materialKs"), ks); shader->bindFloat(shader->getLocation("materialNs"), ns); if(diffuse_texture != NULL) { diffuse_texture->bind(TEX_ID); shader->bindInteger(shader->getLocation("baseTexture"), TEX_ID); } } void PhongMaterial::setTexture(Texture* myTexture) { diffuse_texture = myTexture; updateShader(); }