VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
screenComponent.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3#pragma once
4
5#include <algorithm>
6#include <vector>
7
8#include "core/math/vector2.h"
10
11namespace visutwin::canvas
12{
14 {
15 public:
17 ~ScreenComponent() override;
18
19 void initializeComponentData() override {}
20
21 static const std::vector<ScreenComponent*>& instances() { return _instances; }
22
23 const Vector2& referenceResolution() const { return _referenceResolution; }
24 void setReferenceResolution(const Vector2& value) { _referenceResolution = value; }
25
26 const Vector2& resolution() const { return _resolution; }
27
28 bool screenSpace() const { return _screenSpace; }
29 void setScreenSpace(const bool value) { _screenSpace = value; }
30
31 float scale() const { return _scale; }
32
33 void updateScaleFromWindow(int windowWidth, int windowHeight);
34
35 private:
36 inline static std::vector<ScreenComponent*> _instances;
37
38 Vector2 _referenceResolution = Vector2(1280.0f, 720.0f);
39 Vector2 _resolution = Vector2(1280.0f, 720.0f);
40 bool _screenSpace = true;
41 float _scale = 1.0f;
42 };
43}
Entity * entity() const
Definition component.cpp:16
Component(IComponentSystem *system, Entity *entity)
Definition component.cpp:12
IComponentSystem * system() const
Definition component.h:47
ECS entity — a GraphNode that hosts components defining its behavior.
Definition entity.h:32
const Vector2 & resolution() const
ScreenComponent(IComponentSystem *system, Entity *entity)
void updateScaleFromWindow(int windowWidth, int windowHeight)
static const std::vector< ScreenComponent * > & instances()
void setScreenSpace(const bool value)
const Vector2 & referenceResolution() const
void setReferenceResolution(const Vector2 &value)
2D vector for UV coordinates, screen positions, and 2D math.
Definition vector2.h:18