31 lines
922 B
C++
31 lines
922 B
C++
#include "phongmodule.h"
|
|
#include "lights.h"
|
|
#include "shader.h"
|
|
#include "resourcebase.h"
|
|
#include "phongentity.h"
|
|
#include "camera.h"
|
|
|
|
PhongModule::PhongModule(Lights::Light* myDirLight, Lights* myPointLights) :
|
|
dirLight(myDirLight),
|
|
pointLights(myPointLights),
|
|
shader(ResourceBase::getShader("phong"))
|
|
{
|
|
dirLightLocation = shader->getLocation("dirLight");
|
|
nbPointLightsLocation = shader->getLocation("nbPointLights");
|
|
pointLightsLocation = shader->getLocation("pointLights");
|
|
}
|
|
|
|
void PhongModule::addEntity(PhongEntity* myEntity)
|
|
{
|
|
entities.push_back(myEntity);
|
|
}
|
|
|
|
void PhongModule::renderGL(Camera* myCamera)
|
|
{
|
|
shader->bind();
|
|
shader->bindVec3Array(dirLightLocation, (glm::vec3*)dirLight, 2);
|
|
pointLights->bind(pointLightsLocation, nbPointLightsLocation, shader);
|
|
for(PhongEntity* e : entities)
|
|
e->draw(myCamera->getViewMatrix(), myCamera->getProjectionMatrix());
|
|
}
|