lxgui
Loading...
Searching...
No Matches
gui_gl_vertex_cache.hpp
1#ifndef LXGUI_GUI_GL_VERTEX_CACHE_HPP
2#define LXGUI_GUI_GL_VERTEX_CACHE_HPP
3
4#include "lxgui/gui_vertex_cache.hpp"
5#include "lxgui/utils.hpp"
6
7#include <cstdint>
8#include <limits>
9#include <memory>
10
11namespace lxgui::gui::gl {
12
29class vertex_cache final : public gui::vertex_cache {
30public:
38 explicit vertex_cache(type t);
39
41 ~vertex_cache() override;
42
48 void update_data(const vertex* vertex_data, std::size_t num_vertex);
49
55 void update_indices(const std::uint32_t* vertex_indices, std::size_t num_indices);
56
66 void update_indices_if_grow(const std::uint32_t* vertex_indices, std::size_t num_indices);
67
75 void update(const vertex* vertex_data, std::size_t num_vertex) override;
76
82 void render() const;
83
84private:
85 std::size_t current_size_vertex_ = 0u;
86 std::size_t current_size_index_ = 0u;
87 std::size_t current_capacity_vertex_ = 0u;
88 std::size_t current_capacity_index_ = 0u;
89 std::uint32_t vertex_array_ = std::numeric_limits<std::uint32_t>::max();
90 std::uint32_t vertex_buffer_ = std::numeric_limits<std::uint32_t>::max();
91 std::uint32_t index_buffer_ = std::numeric_limits<std::uint32_t>::max();
92};
93
94} // namespace lxgui::gui::gl
95
96#endif
An object representing cached vertex data on the GPU.
void render() const
Renders the cache.
void update_data(const vertex *vertex_data, std::size_t num_vertex)
Update the data stored in the cache, reusing existing indices.
void update(const vertex *vertex_data, std::size_t num_vertex) override
Update the data stored in the cache to form new triangles.
vertex_cache(type t)
Constructor.
void update_indices(const std::uint32_t *vertex_indices, std::size_t num_indices)
Update the indices stored in the cache, reusing existing data.
void update_indices_if_grow(const std::uint32_t *vertex_indices, std::size_t num_indices)
Update the indices stored in the cache, but only if the current index cache is smaller.
~vertex_cache() override
Destructor.
An object representing cached vertex data on the GPU.
type
The type of vertex data contained in a vertex_cache.
Holds position, texture coordinate, and color information for drawing.