b7456401e0
Added image scene to render an image in a scene. There is also now a testing image that is an uber meme. Currently the problem is that the spritebatch cannot use the offsetof macro because it is a templated class. Possible solutions to this are changing it to be specifyable or implemented per vertex type as the other batches have been.
98 lines
2.1 KiB
C++
98 lines
2.1 KiB
C++
#include "MyApplication.h"
|
|
|
|
MyApplication::MyApplication(int width, int height)
|
|
: Application(width, height),
|
|
m_basic_scene(*this),
|
|
m_simple_2d_scene(*this),
|
|
m_simple_3d_scene(*this),
|
|
m_simple_cube_scene(*this),
|
|
m_builtin_basic_cube_scene(*this),
|
|
m_builtin_lit_scene(*this),
|
|
m_builtin_textured_scene(*this),
|
|
m_builtin_lit_shadowed_scene(*this),
|
|
m_builtin_image_scene(*this)
|
|
{}
|
|
|
|
void MyApplication::init()
|
|
{
|
|
m_basic_scene.init();
|
|
m_simple_2d_scene.init();
|
|
m_simple_3d_scene.init();
|
|
m_simple_cube_scene.init();
|
|
m_builtin_basic_cube_scene.init();
|
|
m_builtin_lit_scene.init();
|
|
m_builtin_textured_scene.init();
|
|
m_builtin_lit_shadowed_scene.init();
|
|
m_builtin_image_scene.init();
|
|
|
|
m_p_current_scene = &m_basic_scene;
|
|
m_p_current_scene->use();
|
|
}
|
|
|
|
void MyApplication::update(float delta_time, clock_t clock)
|
|
{
|
|
if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_1))
|
|
{
|
|
swap_scene(&m_basic_scene);
|
|
}
|
|
else if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_2))
|
|
{
|
|
swap_scene(&m_simple_2d_scene);
|
|
}
|
|
else if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_3))
|
|
{
|
|
swap_scene(&m_simple_3d_scene);
|
|
}
|
|
else if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_4))
|
|
{
|
|
swap_scene(&m_simple_cube_scene);
|
|
}
|
|
else if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_5))
|
|
{
|
|
swap_scene(&m_builtin_basic_cube_scene);
|
|
}
|
|
else if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_6))
|
|
{
|
|
swap_scene(&m_builtin_lit_scene);
|
|
}
|
|
else if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_7))
|
|
{
|
|
swap_scene(&m_builtin_textured_scene);
|
|
}
|
|
else if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_8))
|
|
{
|
|
swap_scene(&m_builtin_lit_shadowed_scene);
|
|
}
|
|
else if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_9))
|
|
{
|
|
swap_scene(&m_builtin_image_scene);
|
|
}
|
|
m_p_current_scene->update(delta_time, clock);
|
|
}
|
|
|
|
void MyApplication::prerender()
|
|
{
|
|
m_p_current_scene->prerender();
|
|
}
|
|
|
|
void MyApplication::render()
|
|
{
|
|
m_p_current_scene->render();
|
|
}
|
|
|
|
void MyApplication::close()
|
|
{
|
|
m_p_current_scene->unuse();
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|