#include "window.h" namespace ui { Window::Window(const char *title, int width, int height) { this->win = SDL_CreateWindow(title, width, height, 0); this->context = new Context(this->win); windows.push_back({SDL_GetWindowID(this->win), this}); float x, y; SDL_GetMouseState(&x, &y); input.mouse.x = int(x); input.mouse.y = int(y); } Window::~Window() { for (size_t i=0; icontext; SDL_DestroyWindow(this->win); } bool Window::HandleEvents(SDL_Event *e) { switch (e->type) { case SDL_EVENT_MOUSE_MOTION: input.mouse.x = e->motion.x; input.mouse.y = e->motion.y; // ... default: break; } } /* MÈTODES ESTATICS */ /* ================ */ std::vector> Window::windows; void Window::DistributeEvent(SDL_Event *e) { uint32_t id = SDL_GetWindowID(SDL_GetWindowFromEvent(e)); for (auto window : Window::windows) if (window.first == id) window.second->HandleEvents(e); } }