SparrowRenderer/phongmodule.cpp

42 lines
827 B
C++

#include "phongmodule.h"
#include "lights.h"
#include "shader.h"
#include "phongentity.h"
#include "camera.h"
#include "mesh.h"
Shader* PhongModule::shaders[NB_SHADERS] = {0, 0};
PhongModule::PhongModule(Lights::Light* myDirLight, Lights* myPointLights) :
dirLight(myDirLight),
pointLights(myPointLights)
{
}
void PhongModule::addEntity(PhongEntity* myEntity)
{
entities.push_back(myEntity);
}
void PhongModule::clearEntities()
{
entities.clear();
}
void PhongModule::renderGL(Camera* myCamera)
{
for(PhongEntity* e : entities)
e->draw(myCamera->getViewMatrix(), myCamera->getProjectionMatrix(), dirLight, pointLights);
}
void PhongModule::setShader(ShaderType slot, Shader* myShader)
{
shaders[slot] = myShader;
}
Shader* PhongModule::getShader(ShaderType slot)
{
return shaders[slot];
}