Add app::impl::get_scene()
This commit is contained in:
parent
807daf3237
commit
29827743f6
1 changed files with 16 additions and 7 deletions
|
|
@ -35,6 +35,8 @@ namespace psemek::app
|
|||
|
||||
struct app::impl
|
||||
{
|
||||
app * parent;
|
||||
|
||||
sdl_initializer init;
|
||||
SDL_Window * window = nullptr;
|
||||
SDL_GLContext gl_context = nullptr;
|
||||
|
|
@ -47,15 +49,26 @@ namespace psemek::app
|
|||
|
||||
clock::time_point start_time;
|
||||
|
||||
impl(app * parent)
|
||||
: parent(parent)
|
||||
{}
|
||||
|
||||
~impl()
|
||||
{
|
||||
if (gl_context) SDL_GL_DeleteContext(gl_context);
|
||||
if (window) SDL_DestroyWindow(window);
|
||||
}
|
||||
|
||||
scene * get_scene()
|
||||
{
|
||||
if (current_scene)
|
||||
return current_scene;
|
||||
return parent;
|
||||
}
|
||||
};
|
||||
|
||||
app::app(std::string const & name)
|
||||
: pimpl_{std::make_unique<struct impl>()}
|
||||
: pimpl_{std::make_unique<struct impl>(this)}
|
||||
{
|
||||
impl().start_time = clock::now();
|
||||
|
||||
|
|
@ -112,9 +125,7 @@ namespace psemek::app
|
|||
|
||||
void app::poll_events()
|
||||
{
|
||||
scene * handler = this;
|
||||
if (impl().current_scene)
|
||||
handler = impl().current_scene;
|
||||
auto handler = impl().get_scene();
|
||||
|
||||
for (SDL_Event e; SDL_PollEvent(&e);) switch (e.type)
|
||||
{
|
||||
|
|
@ -191,9 +202,7 @@ namespace psemek::app
|
|||
{
|
||||
poll_events();
|
||||
|
||||
scene * handler = this;
|
||||
if (impl().current_scene)
|
||||
handler = impl().current_scene;
|
||||
auto handler = impl().get_scene();
|
||||
|
||||
if (!impl().had_initial_resize)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue