aboutsummaryrefslogtreecommitdiff
path: root/src/client/render/render.hh
blob: c98043a84d08bf08093294048bf4069b6ce2ceb0 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef CLIENT_RENDER_RENDER_HH_
#define CLIENT_RENDER_RENDER_HH_

#include <algorithm>
#include <array>
#include <chrono>
#include <cmath>
#include <fstream>
#include <iostream>
#include <optional>
#include <ranges>
#include <unordered_map>

#include <epoxy/gl.h> // this has to go before SDL2
#include <epoxy/glx.h>

#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>

#include <glm/glm.hpp>
#include <glm/gtc/matrix_access.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>

#include <ft2build.h>
#include FT_FREETYPE_H

#include "client/render/camera.hh"
#include "client/render/program.hh"
#include "client/render/struct.hh"
#include "client/render/texture.hh"
#include "shared/shared.hh"
#include "shared/world/chunk.hh"

namespace client {
namespace render {

void init();
void quit() noexcept;

// Getters
int get_fps() noexcept;
SDL_Window* const& get_sdl_window() noexcept;
const glm::ivec2& get_window_size() noexcept;
GLuint get_texture_atlas() noexcept;

// Update
void update_uniforms() noexcept;
void swap_window() noexcept;

// Render
void render_rectangle(const glm::vec2& pos, const glm::vec2& size,
                      const glm::vec4& colour) noexcept;
void render_text(const std::string_view text, const unsigned int size,
                 const bool is_centered, const bool is_vcentered,
                 const glm::vec4& colour, const glm::mat4& matrix) noexcept;
void render_cube_outline(const glm::vec3& pos,
                         const glm::vec4& colour) noexcept;

// Draw is similar to render but more abstracted.
void draw_colour(const glm::vec4& colour) noexcept;

struct rectangle_args {
    relative_arg pos;
    relative_arg size;
    glm::vec4 colour;
};
void draw_rectangle(const rectangle_args& args) noexcept;

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_text(const std::string_view text, const text_args& args) noexcept;

} // namespace render
} // namespace client

#endif