lxgui
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 <limits>
8 #include <memory>
9 
10 namespace lxgui::gui::gl {
11 
28 class vertex_cache final : public gui::vertex_cache {
29 public:
37  explicit vertex_cache(type t);
38 
40  ~vertex_cache() override;
41 
47  void update_data(const vertex* vertex_data, std::size_t num_vertex);
48 
54  void update_indices(const std::uint32_t* vertex_indices, std::size_t num_indices);
55 
65  void update_indices_if_grow(const std::uint32_t* vertex_indices, std::size_t num_indices);
66 
74  void update(const vertex* vertex_data, std::size_t num_vertex) override;
75 
81  void render() const;
82 
83 private:
84  std::size_t current_size_vertex_ = 0u;
85  std::size_t current_size_index_ = 0u;
86  std::size_t current_capacity_vertex_ = 0u;
87  std::size_t current_capacity_index_ = 0u;
88  std::uint32_t vertex_array_ = std::numeric_limits<std::uint32_t>::max();
89  std::uint32_t vertex_buffer_ = std::numeric_limits<std::uint32_t>::max();
90  std::uint32_t index_buffer_ = std::numeric_limits<std::uint32_t>::max();
91 };
92 
93 } // namespace lxgui::gui::gl
94 
95 #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.
Definition: gui_vertex.hpp:12