charcoal/OpenGLEngine/BasicScene.cpp
elipzer d63f341d89 More builtin abstraction
Got the builtin basicscene to render. For some reason, it seems
like the model matrices are not working correctly. The two shapes
that are supposed to be rendering on screen are not moving around
as they should be.
2018-09-13 19:21:34 -04:00

56 lines
1.1 KiB
C++

#include "BasicScene.h"
#include "stdafx.h"
#include "GLUtil.h"
#include "MeshFactory.h"
namespace charcoal
{
namespace builtin
{
void BasicScene::init()
{
for (auto iter = m_batches.begin(); iter != m_batches.end(); ++iter)
{
BasicBatch& batch = *iter;
batch.init();
add_prerenderable(&batch);
}
}
void BasicScene::use()
{
// TODO: move to glutil
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
}
void BasicScene::unuse()
{
}
void BasicScene::render()
{
glutil::clear_screen();
m_shader_program.use();
glutil::uniform_matrix(0, m_p_camera->get_world_to_view_matrix());
for (auto iter = m_batches.begin(); iter != m_batches.end(); ++iter)
{
iter->render();
}
}
BasicBatch& BasicScene::add_batch(BasicRenderable* renderable, int element_count)
{
return add_batch(renderable, element_count, element_count);
}
BasicBatch& BasicScene::add_batch(BasicRenderable* renderable, int element_count, int element_render_count)
{
m_batches.emplace_back(renderable, element_count, element_render_count);
return m_batches.back();
}
}
}