2018-09-04 19:25:54 +00:00
|
|
|
#include "MyApplication.h"
|
|
|
|
|
2018-09-05 15:47:09 +00:00
|
|
|
void MyApplication::init()
|
2018-09-04 19:25:54 +00:00
|
|
|
{
|
2018-09-05 23:10:38 +00:00
|
|
|
m_simple_scene.init();
|
|
|
|
m_object_oriented_scene.init();
|
|
|
|
|
|
|
|
m_p_current_scene = &m_simple_scene;
|
|
|
|
m_p_current_scene->use();
|
2018-09-04 19:25:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyApplication::update(float delta_time, clock_t clock)
|
|
|
|
{
|
2018-09-05 23:10:38 +00:00
|
|
|
if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_1))
|
|
|
|
{
|
|
|
|
swap_scene(&m_simple_scene);
|
|
|
|
}
|
|
|
|
else if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_2))
|
|
|
|
{
|
|
|
|
swap_scene(&m_object_oriented_scene);
|
|
|
|
}
|
|
|
|
m_p_current_scene->update(delta_time, clock);
|
2018-09-04 19:25:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyApplication::render()
|
|
|
|
{
|
2018-09-05 23:10:38 +00:00
|
|
|
m_p_current_scene->render();
|
2018-09-04 19:25:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyApplication::close()
|
|
|
|
{
|
2018-09-05 23:10:38 +00:00
|
|
|
m_p_current_scene->unuse();
|
2018-09-04 19:25:54 +00:00
|
|
|
}
|
|
|
|
|
2018-09-05 23:10:38 +00:00
|
|
|
void MyApplication::swap_scene(Scene* scene)
|
|
|
|
{
|
|
|
|
if (m_p_current_scene != scene)
|
|
|
|
{
|
|
|
|
m_p_current_scene->unuse();
|
|
|
|
m_p_current_scene = scene;
|
|
|
|
m_p_current_scene->use();
|
|
|
|
}
|
|
|
|
}
|
2018-09-04 19:25:54 +00:00
|
|
|
|