blob: fd00ffdf019aed2990773d6558ea4b3327693f77 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
|