Files
vb01/material.cpp
T
devZoGok 9479e3324f implemented shadows for non positional lights
fixed skybox
implemented translation and rotation
2021-10-18 19:05:52 +03:00

51 lines
1.0 KiB
C++
Executable File

#include"material.h"
#include"shader.h"
using namespace std;
namespace vb01{
Material::Material(Type type){
this->type=type;
string basePath="/home/dominykas/c++/vb01/",shaderName;
switch(type){
case MATERIAL_2D:
shaderName="texture.";
break;
case MATERIAL_PARTICLE:
shaderName="particle.";
break;
case MATERIAL_SKYBOX:
shaderName="skybox.";
break;
case MATERIAL_GUI:
shaderName="gui.";
break;
case MATERIAL_TEXT:
shaderName="text.";
break;
}
shader=new Shader(basePath+shaderName+"vert",basePath+shaderName+"frag");
}
Material::~Material(){}
void Material::update(){
shader->use();
if(type==MATERIAL_2D)
shader->setBool(lightingEnabled,"lightingEnabled");
shader->setBool(texturingEnabled,"texturingEnabled");
if(texturingEnabled){
for(Texture *t : diffuseMapTextures)
t->select();
for(Texture *t : normalMapTextures)
t->select();
for(Texture *t : specularMapTextures)
t->select();
}
else{
shader->setVec4(diffuseColor,"diffuseColor");
}
}
}