#include "application.hpp"

namespace VE
{
  application::application(std::string app_name) : m_glfw{ std::make_unique<glfw>() }
  {
    m_instance = std::unique_ptr<application>(this);
    m_glfw->init(app_name);
    m_gui = std::make_unique<gui>(m_glfw);
  }

  void application::run()
  {
    while(!glfwWindowShouldClose(m_glfw->get_win()))
    {
      m_glfw->clear();

      m_gui->begin_frame();
      for (auto l : m_layers_stack) l->render();
      m_gui->end_frame();

      m_glfw->update();
    }
  }

  std::unique_ptr<glfw>& application::get_glfw()
  {
    return m_glfw;
  }

  std::unique_ptr<application>& application::get()
  {
    return m_instance;
  }
}
