32 lines
981 B
C++
32 lines
981 B
C++
#include "phongmodule.h"
|
|
#include "lights.h"
|
|
#include "shader.h"
|
|
#include "resourcebase.h"
|
|
#include "phongentity.h"
|
|
#include "camera.h"
|
|
|
|
PhongModule::PhongModule(Lights* myDirLights, Lights* myPointLights) :
|
|
dirLights(myDirLights),
|
|
pointLights(myPointLights),
|
|
shader(ResourceBase::getShader("phong"))
|
|
{
|
|
nbDirLightsLocation = shader->getLocation("nbDirLights");
|
|
dirLightsLocation = shader->getLocation("dirLights");
|
|
nbPointLightsLocation = shader->getLocation("nbPointLights");
|
|
pointLightsLocation = shader->getLocation("pointLights");
|
|
}
|
|
|
|
void PhongModule::addEntity(PhongEntity* myEntity)
|
|
{
|
|
entities.push_back(myEntity);
|
|
}
|
|
|
|
void PhongModule::renderGL(Camera* myCamera)
|
|
{
|
|
shader->bind();
|
|
dirLights->bind(dirLightsLocation, nbDirLightsLocation, shader);
|
|
pointLights->bind(pointLightsLocation, nbPointLightsLocation, shader);
|
|
for(PhongEntity* e : entities)
|
|
e->draw(myCamera->getViewMatrix(), myCamera->getProjectionMatrix());
|
|
}
|