Loading...
Searching...
No Matches
IWindow.h
Go to the documentation of this file.
1//
2// Created by denzel on 18/09/2025.
3//
4
5#pragma once
6#include <string>
7
8#include "glm/vec2.hpp"
9
10namespace hellfire {
14 SHOWN
15 };
16
17 struct WindowInfo {
18 int width;
19 int height;
20 std::string title;
21 };
22
24 public:
25 virtual ~IWindowEventHandler() = default;
26
27 // @brief Generic input events - no platform-specific parameters
28 virtual void on_key_down(int keycode) {
29 }
30
31 virtual void on_key_up(int keycode) {
32 }
33
34 virtual void on_mouse_button(int button, bool pressed) {
35 }
36
37 virtual void on_mouse_move(float x, float y) {
38 }
39
40 virtual void on_mouse_wheel(float delta) {
41 }
42
43 virtual void on_window_resize(int width, int height) {
44 }
45
46 virtual void on_window_minimize(bool minimized) {
47 }
48
49 virtual void on_render() {
50 }
51 };
52
53 class IWindow {
54 public:
55 virtual ~IWindow() = default;
56
57 // Core window operations
58 virtual bool create(int width, int height, const std::string &title) = 0;
59
60 virtual void destroy() = 0;
61
62 virtual void swap_buffers() = 0;
63
64 virtual void poll_events() = 0;
65
66 virtual void wait_for_events() = 0;
67
68 virtual void set_event_handler(IWindowEventHandler *event_handler) = 0;
69
70 // Window properties
71 virtual void set_title(const std::string &title) = 0;
72
73 virtual void set_size(int width, int height) = 0;
74
75 virtual glm::ivec2 get_size() const = 0;
76
77 virtual glm::ivec2 get_framebuffer_size() const = 0;
78
79 virtual void enable_vsync(bool vsync) = 0;
80
81 // Input handling
82 virtual bool is_key_pressed(int keycode) const = 0;
83
84 virtual glm::vec2 get_mouse_position() const = 0;
85
86 virtual bool should_close() const = 0;
87
88 // Cursor properties
89 virtual void set_cursor_mode(CursorMode mode) = 0;
90
91 // OpenGL context
92 virtual void make_current() = 0;
93
94 virtual void *get_native_handle() = 0;
95
96 virtual float get_elapsed_time() = 0;
97
98 virtual void warp_cursor(double x, double y) = 0;
99
100 protected:
102 };
103}
bool is_valid() const
Definition Shader.h:46
std::vector< std::unique_ptr< IApplicationPlugin > > plugins_
Definition Application.h:97
std::function< bool()> exit_condition_
Definition Application.h:93
AppInfo & get_window_info()
Definition Application.h:59
void on_mouse_move(float x, float y) override
void set_exit_condition(std::function< bool()> condition)
ShaderManager shader_manager_
std::unique_ptr< IWindow > window_
Definition Application.h:98
ShaderRegistry shader_registry_
bool call_plugins_until_consumed(Func &&func)
void on_render() override
std::unique_ptr< InputManager > input_manager_
Definition Application.h:99
Application(int width=800, int height=600, std::string title="hellfire Application")
void handle_cursor_warping(float x, float y) const
bool handle_first_mouse_movement(float x, float y)
void on_key_up(int key) override
void on_key_down(int key) override
void on_window_minimize(bool minimized) override
void register_plugin(std::unique_ptr< IApplicationPlugin > plugin)
Method for registering plugins.
Definition Application.h:61
Shader * ensure_fallback_shader()
void on_mouse_button(int button, bool pressed) override
void call_plugins(Func &&func)
uint32_t create_minimal_fallback_shader()
void on_window_resize(int width, int height) override
virtual bool on_mouse_move(float x, float y, float x_offset, float y_offset)
virtual bool on_mouse_button(int button, bool pressed)
virtual bool on_key_down(int key)
virtual Entity * get_render_camera_override()
virtual void on_initialize(Application &app)
virtual void on_window_resize(int width, int height)
virtual void on_key_up(int keycode)
Definition IWindow.h:31
virtual void on_mouse_move(float x, float y)
Definition IWindow.h:37
virtual void on_window_resize(int width, int height)
Definition IWindow.h:43
virtual ~IWindowEventHandler()=default
virtual void on_key_down(int keycode)
Definition IWindow.h:28
virtual void on_window_minimize(bool minimized)
Definition IWindow.h:46
virtual void on_mouse_button(int button, bool pressed)
Definition IWindow.h:34
virtual void on_render()
Definition IWindow.h:49
virtual void on_mouse_wheel(float delta)
Definition IWindow.h:40
virtual void set_event_handler(IWindowEventHandler *event_handler)=0
virtual bool is_key_pressed(int keycode) const =0
virtual bool should_close() const =0
WindowInfo window_info_
Definition IWindow.h:101
virtual glm::vec2 get_mouse_position() const =0
virtual ~IWindow()=default
virtual void set_size(int width, int height)=0
virtual void poll_events()=0
virtual glm::ivec2 get_framebuffer_size() const =0
virtual void set_title(const std::string &title)=0
virtual void swap_buffers()=0
virtual void enable_vsync(bool vsync)=0
virtual glm::ivec2 get_size() const =0
virtual void * get_native_handle()=0
virtual void warp_cursor(double x, double y)=0
virtual void destroy()=0
virtual void set_cursor_mode(CursorMode mode)=0
virtual bool create(int width, int height, const std::string &title)=0
virtual float get_elapsed_time()=0
virtual void wait_for_events()=0
virtual void make_current()=0
Manages a collection of entities and their hierarchical relationships.
Definition Scene.h:24
@ HIDDEN
Definition IWindow.h:12
@ DISABLED
Definition IWindow.h:13
@ SHOWN
Definition IWindow.h:14
std::string title
Definition Application.h:40
static float delta_time
Definition Time.h:9
static void update()
Definition Time.h:20
static void init()
Definition Time.h:16
std::string title
Definition IWindow.h:20