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"
7
8namespace MayaFlux {
9
14
15std::shared_ptr<Core::Window> create_window(const Core::WindowCreateInfo& create_info)
16{
17 return get_window_manager().create_window(create_info);
18}
19
20glm::vec3 normalize_coords(double window_x, double window_y,
21 uint32_t window_width, uint32_t window_height)
22{
23 return Kinesis::to_ndc(window_x, window_y, window_width, window_height);
24}
25
26glm::vec3 normalize_coords(double window_x, double window_y,
27 const std::shared_ptr<Core::Window>& window)
28{
29 const auto& s = window->get_state();
30 return Kinesis::to_ndc(window_x, window_y, s.current_width, s.current_height);
31}
32
33glm::vec2 window_coords(double ndc_x, double ndc_y, double ndc_z,
34 uint32_t window_width, uint32_t window_height)
35{
36 return Kinesis::to_window({ static_cast<float>(ndc_x), static_cast<float>(ndc_y), static_cast<float>(ndc_z) },
37 window_width, window_height);
38}
39
40glm::vec2 window_coords(double ndc_x, double ndc_y, double ndc_z,
41 const std::shared_ptr<Core::Window>& window)
42{
43 const auto& s = window->get_state();
44 return Kinesis::to_window({ static_cast<float>(ndc_x), static_cast<float>(ndc_y), static_cast<float>(ndc_z) },
45 s.current_width, s.current_height);
46}
47
48glm::vec2 window_coords(const glm::vec3& ndc_pos,
49 uint32_t window_width, uint32_t window_height)
50{
51 return Kinesis::to_window(ndc_pos, window_width, window_height);
52}
53
54glm::vec2 window_coords(const glm::vec3& ndc_pos,
55 const std::shared_ptr<Core::Window>& window)
56{
57 const auto& s = window->get_state();
58 return Kinesis::to_window(ndc_pos, s.current_width, s.current_height);
59}
60
61float aspect_ratio(uint32_t window_width, uint32_t window_height)
62{
63 return Kinesis::aspect_ratio(window_width, window_height);
64}
65
66float aspect_ratio(const std::shared_ptr<Core::Window>& window)
67{
68 const auto& s = window->get_state();
69 return Kinesis::aspect_ratio(s.current_width, s.current_height);
70}
71
72glm::vec3 normalize_coords_aspect(double window_x, double window_y,
73 uint32_t window_width, uint32_t window_height)
74{
75 return Kinesis::to_ndc_aspect(window_x, window_y, window_width, window_height);
76}
77
78glm::vec3 normalize_coords_aspect(double window_x, double window_y,
79 const std::shared_ptr<Core::Window>& window)
80{
81 const auto& s = window->get_state();
82 return Kinesis::to_ndc_aspect(window_x, window_y, s.current_width, s.current_height);
83}
84
85bool is_in_bounds(double window_x, double window_y,
86 uint32_t window_width, uint32_t window_height)
87{
88 return Kinesis::in_bounds(window_x, window_y, window_width, window_height);
89}
90
91bool is_in_bounds(double window_x, double window_y,
92 const std::shared_ptr<Core::Window>& window)
93{
94 const auto& s = window->get_state();
95 return Kinesis::in_bounds(window_x, window_y, s.current_width, s.current_height);
96}
97
98} // 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 GLFW 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.
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:15
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:33
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:85
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:20
Core::Engine & get_context()
Gets the default engine instance.
Definition Core.cpp:68
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:72
float aspect_ratio(uint32_t window_width, uint32_t window_height)
Get window aspect ratio (width/height)
Definition Windowing.cpp:61
Core::WindowManager & get_window_manager()
Gets a handle to default window manager.
Definition Windowing.cpp:10
Main namespace for the Maya Flux audio engine.
Definition Runtime.cpp:12
Configuration for creating a single window instance.