1eea92a3af
Now, LitScene allows for simple lighting. (Shadows still to come). Ambient, specular, and diffuse lighting available and each mesh's vertex can define a material that defines its reflectivity. An example scene was added to the MyApplication as the scene for the 6 button.
49 lines
910 B
C++
49 lines
910 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();
|
|
glutil::uniform_matrix(0, m_p_camera->get_world_to_view_matrix());
|
|
glutil::uniform_vec3(4, m_p_camera->get_position());
|
|
glutil::uniform_uint(5, (unsigned int)m_lights.size());
|
|
glutil::uniform_lights(6, m_lights);
|
|
for (auto iter = m_batches.begin(); iter != m_batches.end(); ++iter)
|
|
{
|
|
iter->render();
|
|
}
|
|
}
|
|
}
|
|
} |