Added events

This commit is contained in:
Robert 2020-06-15 21:49:10 +02:00
parent 9ce9cd3432
commit fd43b8917c
3 changed files with 21 additions and 1 deletions

View file

@ -62,6 +62,11 @@ namespace sf
}
void IWindow::AddEventCallback(EventCallback callback, void* userdata)
{
SDL_AddEventWatch(*(callback.target<SDL_EventFilter>()), userdata);
}
IWindow::IWindow(Vector2u size, Vector2i position, std::string title,
Uint32 flags /*= SDL_WINDOW_RESIZABLE*/) :
m_pWindow(nullptr), m_pRenderer(nullptr), m_oEvent(),
@ -83,6 +88,8 @@ namespace sf
{
while (SDL_PollEvent(&m_oEvent))
{
OnEvent(m_oEvent);
if (m_oEvent.type == SDL_QUIT)
{
m_atomWindowOpen = false;