aboutsummaryrefslogtreecommitdiff
path: root/src/client/render/struct.hh
diff options
context:
space:
mode:
authorNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-12 21:57:46 +1100
committerNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-12 21:57:46 +1100
commite4483eca01b48b943cd0461e24a74ae1a3139ed4 (patch)
treeed58c3c246e3af1af337697695d780aa31f6ad9a /src/client/render/struct.hh
parent1cc08c51eb4b0f95c30c0a98ad1fc5ad3459b2df (diff)
Update to most recent version (old initial commit)
Diffstat (limited to 'src/client/render/struct.hh')
-rw-r--r--src/client/render/struct.hh29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/client/render/struct.hh b/src/client/render/struct.hh
new file mode 100644
index 0000000..fd00ffd
--- /dev/null
+++ b/src/client/render/struct.hh
@@ -0,0 +1,29 @@
+#ifndef CLIENT_RENDER_STRUCT_HH_
+#define CLIENT_RENDER_STRUCT_HH_
+
+//#include <client/render/render.hh>
+#include <glm/glm.hpp>
+
+namespace client {
+namespace render {
+
+const glm::ivec2& get_window_size() noexcept; // forward declaration
+
+// Scale takes the range [0, 1] and represents an amount of the screen.
+// Offset is any value that is added after scale.
+struct relative_arg {
+ glm::vec2 extent;
+ glm::vec2 offset;
+
+ glm::vec2 to_vec2() const noexcept {
+ const glm::vec2& window = render::get_window_size();
+ const float x = this->extent.x * window.x + this->offset.x;
+ const float y = this->extent.y * window.y + this->offset.y;
+ return {x, y};
+ }
+};
+
+} // namespace render
+} // namespace client
+
+#endif