charcoal/OpenGLEngine/LitScene.cpp
2018-09-14 18:09:43 -04:00

53 lines
936 B
C++

#include "LitScene.h"
#include "stdafx.h"
#include "Util.h"
#include "GLUtil.h"
#include "MeshFactory.h"
namespace charcoal
{
namespace builtin
{
void LitScene::init()
{
for (auto iter = m_batches.begin(); iter != m_batches.end(); ++iter)
{
LitBatch& batch = *iter;
batch.init();
add_prerenderable(&batch);
}
}
void LitScene::use()
{
// TODO: move to glutil
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
}
void LitScene::unuse()
{
}
void LitScene::render()
{
glutil::clear_screen();
m_shader_program.use();
CHECK_GL_ERR();
glutil::uniform_matrix(0, m_p_camera->get_world_to_view_matrix());
CHECK_GL_ERR();
glutil::uniform_lights(4, m_lights);
CHECK_GL_ERR();
glutil::uniform_uint(20, m_lights.size());
CHECK_GL_ERR();
for (auto iter = m_batches.begin(); iter != m_batches.end(); ++iter)
{
iter->render();
}
CHECK_GL_ERR();
}
}
}