charcoal/OpenGLEngine/MyApplication.cpp

55 lines
1.0 KiB
C++
Raw Normal View History

2018-09-04 19:25:54 +00:00
#include "MyApplication.h"
MyApplication::MyApplication(int width, int height)
2018-09-11 05:18:17 +00:00
: Application(width, height), m_basic_scene(*this), m_simple_2d_scene(*this), m_simple_3d_scene(*this)
{
}
void MyApplication::init()
2018-09-04 19:25:54 +00:00
{
2018-09-11 05:18:17 +00:00
m_basic_scene.init();
m_simple_2d_scene.init();
m_simple_3d_scene.init();
2018-09-11 05:18:17 +00:00
m_p_current_scene = &m_basic_scene;
m_p_current_scene->use();
2018-09-04 19:25:54 +00:00
}
void MyApplication::update(float delta_time, clock_t clock)
{
if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_1))
{
2018-09-11 05:18:17 +00:00
swap_scene(&m_basic_scene);
}
else if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_2))
{
2018-09-11 05:18:17 +00:00
swap_scene(&m_simple_2d_scene);
}
else if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_3))
{
2018-09-11 05:18:17 +00:00
swap_scene(&m_simple_3d_scene);
}
m_p_current_scene->update(delta_time, clock);
2018-09-04 19:25:54 +00:00
}
void MyApplication::render()
{
m_p_current_scene->render();
2018-09-04 19:25:54 +00:00
}
void MyApplication::close()
{
m_p_current_scene->unuse();
2018-09-04 19:25:54 +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