Implemented WindowsWindow and EventCallback

This commit is contained in:
Simon Lübeß
2020-11-08 18:21:54 +01:00
parent 634f310b7f
commit aa2165ef77
4 changed files with 331 additions and 44 deletions
+17 -3
View File
@@ -1,11 +1,12 @@
using GlitchyEngine.Platform.Windows;
using GlitchyEngine.Events;
namespace GlitchyEngine
{
public class Application
{
private Window _window ~ delete _;
private bool _running;
private bool _running = true;
public bool IsRunning => _running;
@@ -13,16 +14,29 @@ namespace GlitchyEngine
{
// Todo: make Platform independent
_window = new WindowsWindow(WindowDescription());
_window.EventCallback = new => OnEvent;
}
public void Run()
{
_running = true;
while(_running)
{
_window.Update();
}
}
public void OnEvent(Event e)
{
EventDispatcher dispatcher = scope .(e);
dispatcher.Dispatch<WindowCloseEvent>(scope => OnWindowClose);
Log.EngineLogger.Trace("{}", e);
}
public bool OnWindowClose(WindowCloseEvent e)
{
_running = false;
return true;
}
}
}