mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
fixing issue with text destruction
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/11 00:11:56 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/18 13:56:50 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/02/25 09:01:46 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -19,6 +19,8 @@ namespace mlx
|
||||
void Text::init(std::string text, FontID font, std::vector<Vertex> vbo_data, std::vector<std::uint16_t> ibo_data)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
if(_is_init)
|
||||
return;
|
||||
_text = std::move(text);
|
||||
_font = font;
|
||||
#ifdef DEBUG
|
||||
@@ -36,11 +38,14 @@ namespace mlx
|
||||
_vbo[i].create(sizeof(Vertex) * vbo_data.size(), static_cast<const void*>(vbo_data.data()), nullptr);
|
||||
_ibo.create(sizeof(std::uint16_t) * ibo_data.size(), ibo_data.data(), nullptr);
|
||||
#endif
|
||||
_is_init = true;
|
||||
}
|
||||
|
||||
void Text::bind(Renderer& renderer) noexcept
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
if(!_is_init)
|
||||
return;
|
||||
_vbo[renderer.getActiveImageIndex()].bind(renderer);
|
||||
_ibo.bind(renderer);
|
||||
}
|
||||
@@ -48,14 +53,24 @@ namespace mlx
|
||||
void Text::updateVertexData(int frame, std::vector<Vertex> vbo_data)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
if(!_is_init)
|
||||
return;
|
||||
_vbo[frame].setData(sizeof(Vertex) * vbo_data.size(), static_cast<const void*>(vbo_data.data()));
|
||||
}
|
||||
|
||||
void Text::destroy() noexcept
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
if(!_is_init)
|
||||
return;
|
||||
for(int i = 0; i < MAX_FRAMES_IN_FLIGHT; i++)
|
||||
_vbo[i].destroy();
|
||||
_ibo.destroy();
|
||||
_is_init = false;
|
||||
}
|
||||
|
||||
Text::~Text()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user