Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
IWindow.h
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2025-2026 Manuel Osorio
3#pragma once
4#include "flint/graphics/types/color.h"
5#include "flint/input/event.h"
6#include "flint/math/types.h"
7
8#include <functional>
9#include <string>
10
11namespace Flint {
15 enum class CursorType {
16 Arrow,
17 Hand
18 };
19
27 class IWindow {
28 public:
32 virtual void display() = 0;
33
39 virtual void setMouseCursor(CursorType type) = 0;
40
44 virtual bool isOpen() const = 0;
45
51 virtual void pollEvents(const std::function<void(const AppEvent &)> &handler) = 0;
52
58 virtual void setTitle(const std::string &name) = 0;
59
65 virtual void close() = 0;
66 virtual ~IWindow() = default;
67
71 virtual Vec2f getMousePosition() const = 0;
72
76 virtual Vec2f mapPixelToCoords(Vec2f pixel) const = 0;
77
81 virtual Vec2i getSize() const = 0;
82
90 virtual void addGlobalEventListener(std::function<void(const AppEvent &)> callback) = 0;
91
95 virtual bool hasFocus() const = 0;
96
104 virtual void *getNativeHandle() const = 0;
105
109 virtual bool isFullscreen() const = 0;
110
116 virtual void setFullscreen(bool fullscreen) = 0;
117 };
118}
virtual void display()=0
Present the current frame to the screen.
virtual Vec2f mapPixelToCoords(Vec2f pixel) const =0
Return the current mouse cursor position in window-space pixels.
virtual void pollEvents(const std::function< void(const AppEvent &)> &handler)=0
Poll all pending OS events and dispatch them to handler.
virtual Vec2i getSize() const =0
Return the current window size in pixels.
virtual bool isFullscreen() const =0
Return true if the window is currently in fullscreen mode.
virtual void close()=0
Request that the window close.
virtual bool isOpen() const =0
Return true if the window is open and the application should keep running.
virtual Vec2f getMousePosition() const =0
Return the current mouse cursor position in window-space pixels.
virtual bool hasFocus() const =0
Return true if the window currently has input focus.
virtual void addGlobalEventListener(std::function< void(const AppEvent &)> callback)=0
Register a global event listener that receives every polled event.
virtual void setTitle(const std::string &name)=0
Set the window title bar text.
virtual void setFullscreen(bool fullscreen)=0
Enter or exit fullscreen mode.
virtual void setMouseCursor(CursorType type)=0
Set the mouse cursor shape.
virtual void * getNativeHandle() const =0
Return the platform-native window handle (e.g. HWND, SDL_Window*).
Abstract interface for a platform window.
Definition IWindow.h:27
A tagged union representing a single application input or window event.
Definition event.h:90