1#include <include/imgui/imgui_impl_sdl3.h>
2#include <zen/core/ZEN_Application.h>
3#include <zen/core/ZEN_Window.h>
4#include <zen/gui/ZEN_ImGuiLayer.h>
5#include <zen/inputs/ZEN_Input.h>
6#include <zen/log/ZEN_Log.h>
7#include <zen/particles/ZEN_ParticleTestLayer.h>
8#include <zen/time/ZEN_EngineTime.h>
13 Application::Application() {
17 WindowProperties properties = {
"Zen Window Test", 1280, 720,
true,
false};
18 m_eventsDispatcher.registerListener(
this);
19 m_window = Window::create(properties);
20 m_eventsDispatcher.registerListener(m_window.get());
22 ZEN_LOG_DEBUG(
"new ImGui");
23 m_ImGui =
new ImGuiLayer;
29 Application::~Application() {
33 bool Application::onEvent(
const ZenEvent &event) {
34 if (event.header.type == EventType::Quit) {
35 ZEN_LOG_INFO(
"Quitting!");
42 void Application::run() {
43 ZEN_LOG_INFO(
"Running Application...");
45 float currentTime = EngineTime::getTime();
47 DeltaTime dt = currentTime - m_previousTime;
48 m_previousTime = currentTime;
50 m_inputSystem.begin();
52 SDL_Event eventFromSDL;
53 while (SDL_PollEvent(&eventFromSDL)) {
54 ImGui_ImplSDL3_ProcessEvent(&eventFromSDL);
56 ZenEvent e = TranslateEvent(eventFromSDL);
57 if (e.header.type != EventType::None) {
58 m_eventBuffer.enqueue(e);
62 while (!m_eventBuffer.isEmpty()) {
63 m_eventsDispatcher.dispatch(m_eventBuffer.dequeue());
66 Input::bind(&m_inputSystem);
67 for (
auto &layer : m_layerList) {
71 for (
auto &layer : m_layerList) {
81 ZEN_LOG_INFO(
"Closing Application...");
84 void Application::onUpdate(
DeltaTime deltaTime) {}
86 void Application::pushLayer(
Layer *layer) {
87 m_layerList.pushLayer(layer);
88 m_eventsDispatcher.registerListener(layer);
92 void Application::pushOverlay(
Layer *overlay) {
93 m_layerList.pushLayer(overlay);
94 m_eventsDispatcher.registerListener(overlay);
98 void Application::popLayer(
Layer *layer) {
99 m_layerList.popLayer(layer);
100 m_eventsDispatcher.unregisterListener(layer);
103 void Application::popOverlay(
Layer *overlay) {
104 m_layerList.popLayer(overlay);
105 m_eventsDispatcher.unregisterListener(overlay);
108 Application &Application::get() {
return *s_instance; }
110 Window &Application::getWindow() {
return *m_window; };
112 int Application::getPriority()
const {
return 1; }