diff options
| author | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2025-02-12 18:05:18 +1100 |
|---|---|---|
| committer | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2025-02-12 18:05:18 +1100 |
| commit | 1cc08c51eb4b0f95c30c0a98ad1fc5ad3459b2df (patch) | |
| tree | 222dfcd07a1e40716127a347bbfd7119ce3d0984 /src/client/draw.hh | |
initial commit
Diffstat (limited to 'src/client/draw.hh')
| -rw-r--r-- | src/client/draw.hh | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/client/draw.hh b/src/client/draw.hh new file mode 100644 index 0000000..821d67b --- /dev/null +++ b/src/client/draw.hh @@ -0,0 +1,59 @@ +#ifndef CLIENT_DRAW_HH_ +#define CLIENT_DRAW_HH_ + +#include <string_view> + +#include <glm/glm.hpp> + +#include "client/movement.hh" +#include "client/player.hh" +#include "client/render/camera.hh" +#include "client/render/render.hh" +#include "client/render/program.hh" +#include "client/shared.hh" +#include "client/window.hh" +#include "client/world.hh" + +namespace client { +namespace draw { + +// 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}; + } +}; + +struct rectangle_args { + relative_arg pos; + relative_arg size; + glm::vec4 colour; +}; + +struct text_args { + relative_arg pos; + float extent_height; // we don't get width here, + float offset_height; + glm::vec4 colour; + bool has_backing; + bool is_centered; + bool is_vcentered; +}; + +void draw_rectangle(const rectangle_args& args) noexcept; +void draw_colour(const glm::vec4& colour) noexcept; +void draw_text(const std::string_view text, const text_args& args) noexcept; + +void draw(client::players& players, client::world::chunk::map& chunks) noexcept; + +} // namespace draw +} // namespace client + +#endif |
