SparrowRenderer/crappymodule.cpp

34 lines
1006 B
C++

#include "crappymodule.h"
#include "camera.h"
#include "phongentity.h"
#include <glm/ext.hpp>
CrappyModule::CrappyModule(Lights::Light* myDirLight, Lights* myPointLights) :
dirLight(myDirLight),
pointLights(myPointLights)
{
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_AMBIENT, glm::value_ptr(glm::vec4(glm::vec3(0.1f), 1)));
glLightfv(GL_LIGHT0, GL_POSITION, glm::value_ptr(glm::vec4(dirLight->position, 0)));
// TODO add point lights
}
void CrappyModule::renderGL(Camera* myCamera)
{
glLightfv(GL_LIGHT0, GL_DIFFUSE, glm::value_ptr(glm::vec4(dirLight->color, 1)));
glLightfv(GL_LIGHT0, GL_SPECULAR, glm::value_ptr(glm::vec4(dirLight->color, 1)));
for(PhongEntity* e : entities)
e->crappyDraw(myCamera->getViewMatrix(), myCamera->getProjectionMatrix(), dirLight, pointLights);
}
void CrappyModule::addEntity(PhongEntity* myEntity)
{
entities.push_back(myEntity);
}
void CrappyModule::clearEntities()
{
entities.clear();
}