2018-09-15 21:40:49 +00:00
|
|
|
#include "TexturedScene.h"
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
|
|
#include "GLUtil.h"
|
|
|
|
#include "MeshFactory.h"
|
|
|
|
|
|
|
|
namespace charcoal
|
|
|
|
{
|
|
|
|
namespace builtin
|
|
|
|
{
|
2018-09-19 07:52:42 +00:00
|
|
|
namespace textured
|
2018-09-15 21:40:49 +00:00
|
|
|
{
|
2018-09-19 07:52:42 +00:00
|
|
|
void Scene::init()
|
2018-09-15 21:40:49 +00:00
|
|
|
{
|
2018-09-19 07:52:42 +00:00
|
|
|
for (auto iter = m_batches.begin(); iter != m_batches.end(); ++iter)
|
|
|
|
{
|
|
|
|
Batch& batch = *iter;
|
|
|
|
batch.init();
|
|
|
|
add_prerenderable(&batch);
|
|
|
|
}
|
2018-09-15 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2018-09-19 07:52:42 +00:00
|
|
|
void Scene::use()
|
|
|
|
{
|
|
|
|
// TODO: move to glutil
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
glDepthFunc(GL_LESS);
|
|
|
|
}
|
2018-09-15 21:40:49 +00:00
|
|
|
|
2018-09-19 07:52:42 +00:00
|
|
|
void Scene::unuse()
|
|
|
|
{
|
2018-09-15 21:40:49 +00:00
|
|
|
|
2018-09-19 07:52:42 +00:00
|
|
|
}
|
2018-09-15 21:40:49 +00:00
|
|
|
|
2018-09-19 07:52:42 +00:00
|
|
|
void Scene::render()
|
2018-09-15 21:40:49 +00:00
|
|
|
{
|
2018-09-19 07:52:42 +00:00
|
|
|
glutil::clear_screen();
|
|
|
|
m_shader_program.use();
|
|
|
|
glutil::uniform_matrix(0, m_p_camera->get_world_to_view_matrix());
|
|
|
|
glutil::uniform_int(4, 0); // The textured batch uses GL_TEXTURE0
|
|
|
|
for (auto iter = m_batches.begin(); iter != m_batches.end(); ++iter)
|
|
|
|
{
|
|
|
|
iter->render();
|
|
|
|
}
|
2018-09-15 21:40:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|