vkmEngine 1.0.15
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
screen_view.h
1#pragma once
2
3#include <optional>
4
5#include <glm/glm.hpp>
6
7#include "core/math/bounds.h"
8
9namespace Vkm::Engine {
10
11class HostChrome;
12class Scene;
13class WindowManager;
14struct UICanvas;
15
26class ScreenView {
27 public:
28 ScreenView() = default;
29 ~ScreenView() = default;
30
31 ScreenView(const ScreenView& other) = default;
32 ScreenView& operator=(const ScreenView& other) = default;
33
34 ScreenView(ScreenView && other) = default;
35 ScreenView& operator=(ScreenView && other) = default;
36
37 public:
46 static ScreenView of(const Scene& scene, const WindowManager& window, const HostChrome& chrome);
47
48 bool valid() const { return m_valid; }
49
57 std::optional<Math::Ray> rayThrough(const glm::vec2& windowPoint) const;
58
69 std::optional<glm::vec2> toCanvas(const glm::vec3& world, const UICanvas& canvas) const;
70
71 private:
72 bool m_valid = false;
73 glm::mat4 m_viewProjection{1.0f};
74 glm::vec2 m_origin{0.0f};
75 glm::vec2 m_size{0.0f};
76 float m_pointerScale = 1.0f;
77};
78
79} // namespace Vkm::Engine
What an authoring host tells the engine about the frame it draws over.
Definition host_chrome.h:18
Central registry managing entities and an open set of component types.
Definition scene.h:29
static ScreenView of(const Scene &scene, const WindowManager &window, const HostChrome &chrome)
The view as it stands now.
std::optional< glm::vec2 > toCanvas(const glm::vec3 &world, const UICanvas &canvas) const
Where a point of the world lands on a canvas, in the canvas's own pixels.
std::optional< Math::Ray > rayThrough(const glm::vec2 &windowPoint) const
The ray from the camera through a point of the window.
Owns the application's window, its WindowSurface, input, and frame limiting.
Definition window_manager.h:69
Root of a screen-space UI layer.
Definition ui_canvas.h:18