MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Windowing.cpp
Go to the documentation of this file.
1#include "Windowing.hpp"
2
3#include "Core.hpp"
6
7namespace MayaFlux {
8
13
14std::shared_ptr<Core::Window> create_window(const Core::WindowCreateInfo& create_info)
15{
16 return get_window_manager().create_window(create_info);
17}
18
19glm::vec3 normalize_coords(double window_x, double window_y,
20 uint32_t window_width, uint32_t window_height)
21{
22 return Kinesis::to_ndc(window_x, window_y, window_width, window_height);
23}
24
25glm::vec3 normalize_coords(double window_x, double window_y,
26 const std::shared_ptr<Core::Window>& window)
27{
28 const auto& s = window->get_state();
29 return Kinesis::to_ndc(window_x, window_y, s.current_width, s.current_height);
30}
31
32glm::vec2 window_coords(double ndc_x, double ndc_y, double ndc_z,
33 uint32_t window_width, uint32_t window_height)
34{
35 return Kinesis::to_window({ static_cast<float>(ndc_x), static_cast<float>(ndc_y), static_cast<float>(ndc_z) },
36 window_width, window_height);
37}
38
39glm::vec2 window_coords(double ndc_x, double ndc_y, double ndc_z,
40 const std::shared_ptr<Core::Window>& window)
41{
42 const auto& s = window->get_state();
43 return Kinesis::to_window({ static_cast<float>(ndc_x), static_cast<float>(ndc_y), static_cast<float>(ndc_z) },
44 s.current_width, s.current_height);
45}
46
47glm::vec2 window_coords(const glm::vec3& ndc_pos,
48 uint32_t window_width, uint32_t window_height)
49{
50 return Kinesis::to_window(ndc_pos, window_width, window_height);
51}
52
53glm::vec2 window_coords(const glm::vec3& ndc_pos,
54 const std::shared_ptr<Core::Window>& window)
55{
56 const auto& s = window->get_state();
57 return Kinesis::to_window(ndc_pos, s.current_width, s.current_height);
58}
59
60float aspect_ratio(uint32_t window_width, uint32_t window_height)
61{
62 return Kinesis::aspect_ratio(window_width, window_height);
63}
64
65float aspect_ratio(const std::shared_ptr<Core::Window>& window)
66{
67 const auto& s = window->get_state();
68 return Kinesis::aspect_ratio(s.current_width, s.current_height);
69}
70
71glm::vec3 normalize_coords_aspect(double window_x, double window_y,
72 uint32_t window_width, uint32_t window_height)
73{
74 return Kinesis::to_ndc_aspect(window_x, window_y, window_width, window_height);
75}
76
77glm::vec3 normalize_coords_aspect(double window_x, double window_y,
78 const std::shared_ptr<Core::Window>& window)
79{
80 const auto& s = window->get_state();
81 return Kinesis::to_ndc_aspect(window_x, window_y, s.current_width, s.current_height);
82}
83
84bool is_in_bounds(double window_x, double window_y,
85 uint32_t window_width, uint32_t window_height)
86{
87 return Kinesis::in_bounds(window_x, window_y, window_width, window_height);
88}
89
90bool is_in_bounds(double window_x, double window_y,
91 const std::shared_ptr<Core::Window>& window)
92{
93 const auto& s = window->get_state();
94 return Kinesis::in_bounds(window_x, window_y, s.current_width, s.current_height);
95}
96
97glm::uvec2 normalized_size_to_pixels(const glm::vec2& ndc_size,
98 uint32_t window_width, uint32_t window_height)
99{
100 return Kinesis::ndc_size_to_pixels(ndc_size, window_width, window_height);
101}
102
103glm::uvec2 normalized_size_to_pixels(const glm::vec2& ndc_size,
104 const std::shared_ptr<Core::Window>& window)
105{
106 const auto& s = window->get_state();
107 return Kinesis::ndc_size_to_pixels(ndc_size, s.current_width, s.current_height);
108}
109
111 uint32_t window_width, uint32_t window_height)
112{
113 return Kinesis::ndc_size_to_pixels(region, window_width, window_height);
114}
115
117 const std::shared_ptr<Core::Window>& window)
118{
119 const auto& s = window->get_state();
120 return Kinesis::ndc_size_to_pixels(region, s.current_width, s.current_height);
121}
122
123} // namespace MayaFlux
Core engine lifecycle and configuration API.
std::shared_ptr< WindowManager > get_window_manager()
Gets the window manager.
Definition Engine.hpp:294
std::shared_ptr< Window > create_window(const WindowCreateInfo &create_info)
Creates a new window.
Manages window lifecycle and Window backend event polling.
glm::vec2 to_window(const glm::vec3 &ndc, uint32_t width, uint32_t height)
Convert NDC to window pixel coordinates.
float aspect_ratio(uint32_t width, uint32_t height)
Aspect ratio from pixel dimensions.
glm::uvec2 ndc_size_to_pixels(const AABB2D &region, uint32_t width, uint32_t height)
Convert an NDC AABB's extent to integer pixel dimensions.
Definition Bounds.hpp:443
bool in_bounds(double window_x, double window_y, uint32_t width, uint32_t height)
Check if a window-space point is within bounds.
glm::vec3 to_ndc(double window_x, double window_y, uint32_t width, uint32_t height)
Convert window pixel coordinates to NDC.
glm::vec3 to_ndc_aspect(double window_x, double window_y, uint32_t width, uint32_t height)
Convert window pixel coordinates to NDC, corrected for aspect ratio.
std::shared_ptr< Core::Window > create_window(const Core::WindowCreateInfo &create_info)
Create a new window with specified parameters.
Definition Windowing.cpp:14
glm::vec2 window_coords(double ndc_x, double ndc_y, double ndc_z, uint32_t window_width, uint32_t window_height)
Convert NDC coordinates to window pixel coordinates.
Definition Windowing.cpp:32
bool is_in_bounds(double window_x, double window_y, uint32_t window_width, uint32_t window_height)
Check if a point in window coordinates is inside the window bounds.
Definition Windowing.cpp:84
glm::vec3 normalize_coords(double window_x, double window_y, uint32_t window_width, uint32_t window_height)
Convert window pixel coordinates to normalized device coordinates (NDC)
Definition Windowing.cpp:19
Core::Engine & get_context()
Gets the default engine instance.
Definition Core.cpp:68
glm::uvec2 normalized_size_to_pixels(const glm::vec2 &ndc_size, uint32_t window_width, uint32_t window_height)
Convert an NDC-space size (extent) to integer pixel dimensions.
Definition Windowing.cpp:97
glm::vec3 normalize_coords_aspect(double window_x, double window_y, uint32_t window_width, uint32_t window_height)
Normalize coordinates preserving aspect ratio (useful for circular/square shapes)
Definition Windowing.cpp:71
float aspect_ratio(uint32_t window_width, uint32_t window_height)
Get window aspect ratio (width/height)
Definition Windowing.cpp:60
Core::WindowManager & get_window_manager()
Gets a handle to default window manager.
Definition Windowing.cpp:9
Main namespace for the Maya Flux audio engine.
Definition Runtime.cpp:12
Configuration for creating a single window instance.
Axis-aligned bounding rectangle in a 2D coordinate space.
Definition Bounds.hpp:21