mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 14:43:34 +00:00
fixing new gcc warning in GPU allocator, fixing #55
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 17:55:21 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/14 20:01:01 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/03/25 16:16:07 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -23,7 +23,7 @@ typedef struct
|
||||
void* img;
|
||||
} mlx_t;
|
||||
|
||||
void* img = NULL;
|
||||
//void* img = NULL;
|
||||
|
||||
int update(void* param)
|
||||
{
|
||||
@@ -32,13 +32,13 @@ int update(void* param)
|
||||
|
||||
if(i == 200)
|
||||
mlx_clear_window(mlx->mlx, mlx->win);
|
||||
|
||||
/*
|
||||
if(img)
|
||||
mlx_destroy_image(mlx->mlx,img);
|
||||
img = mlx_new_image(mlx->mlx, 800, 800);
|
||||
mlx_set_image_pixel(mlx->mlx, img, 4, 4, 0xFF00FF00);
|
||||
mlx_put_image_to_window(mlx->mlx, mlx->win, img, 0, 0);
|
||||
|
||||
*/
|
||||
if(i >= 250)
|
||||
mlx_set_font_scale(mlx->mlx, mlx->win, "default", 16.f);
|
||||
else
|
||||
@@ -157,7 +157,11 @@ int main(void)
|
||||
mlx_put_image_to_window(mlx.mlx, mlx.win, mlx.logo_png, 10, 190);
|
||||
|
||||
mlx.img = create_image(&mlx);
|
||||
|
||||
|
||||
|
||||
mlx_string_put(mlx.mlx, mlx.win, 0, 10, 0xFFFFFF00, "fps:");
|
||||
mlx_string_put(mlx.mlx, mlx.win, 0, 20, 0xFFFFFFFF, "fps:");
|
||||
|
||||
mlx_set_font_scale(mlx.mlx, mlx.win, "font.ttf", 16.f);
|
||||
mlx_string_put(mlx.mlx, mlx.win, 20, 20, 0xFF0020FF, "that text will disappear");
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/10/20 02:13:03 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/03 15:25:56 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/03/25 16:01:06 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -44,8 +44,8 @@ namespace mlx
|
||||
|
||||
private:
|
||||
VmaAllocator _allocator;
|
||||
std::uint32_t _active_buffers_allocations = 0;
|
||||
std::uint32_t _active_images_allocations = 0;
|
||||
std::int32_t _active_buffers_allocations = 0;
|
||||
std::int32_t _active_images_allocations = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/11 00:11:56 by maldavid #+# #+# */
|
||||
/* Updated: 2024/02/25 09:01:46 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/03/25 16:13:08 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -16,12 +16,13 @@
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
void Text::init(std::string text, FontID font, std::vector<Vertex> vbo_data, std::vector<std::uint16_t> ibo_data)
|
||||
void Text::init(std::string text, FontID font, std::uint32_t color, std::vector<Vertex> vbo_data, std::vector<std::uint16_t> ibo_data)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
if(_is_init)
|
||||
return;
|
||||
_text = std::move(text);
|
||||
_color = color;
|
||||
_font = font;
|
||||
#ifdef DEBUG
|
||||
std::string debug_name = _text;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/11 00:09:04 by maldavid #+# #+# */
|
||||
/* Updated: 2024/02/25 09:00:26 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/03/25 16:16:48 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -27,12 +27,13 @@ namespace mlx
|
||||
public:
|
||||
Text() = default;
|
||||
|
||||
void init(std::string text, FontID font, std::vector<Vertex> vbo_data, std::vector<std::uint16_t> ibo_data);
|
||||
void init(std::string text, FontID font, std::uint32_t color, std::vector<Vertex> vbo_data, std::vector<std::uint16_t> ibo_data);
|
||||
void bind(class Renderer& renderer) noexcept;
|
||||
inline FontID getFontInUse() const noexcept { return _font; }
|
||||
void updateVertexData(int frame, std::vector<Vertex> vbo_data);
|
||||
inline std::uint32_t getIBOsize() noexcept { return _ibo.getSize(); }
|
||||
inline const std::string& getText() const { return _text; }
|
||||
inline std::uint32_t getColor() const noexcept { return _color; }
|
||||
void destroy() noexcept;
|
||||
|
||||
~Text();
|
||||
@@ -41,6 +42,7 @@ namespace mlx
|
||||
std::array<D_VBO, MAX_FRAMES_IN_FLIGHT> _vbo;
|
||||
C_IBO _ibo;
|
||||
std::string _text;
|
||||
std::uint32_t _color;
|
||||
FontID _font = nullfont;
|
||||
bool _is_init = false;
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/11 00:23:11 by maldavid #+# #+# */
|
||||
/* Updated: 2024/02/25 07:58:21 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/03/25 16:13:48 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace mlx
|
||||
}
|
||||
}
|
||||
std::shared_ptr<Text> text_data = std::make_shared<Text>();
|
||||
text_data->init(_text, font, std::move(vertexData), std::move(indexData));
|
||||
text_data->init(_text, font, color, std::move(vertexData), std::move(indexData));
|
||||
id = TextLibrary::get().addTextToLibrary(text_data);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/10 11:59:57 by maldavid #+# #+# */
|
||||
/* Updated: 2024/03/14 17:31:55 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/03/25 16:17:06 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace mlx
|
||||
std::shared_ptr<Text> TextLibrary::getTextData(TextID id)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
if(!_cache.count(id) || std::find(_invalid_ids.begin(), _invalid_ids.end(), id) != _invalid_ids.end())
|
||||
if(!_cache.count(id))
|
||||
core::error::report(e_kind::fatal_error, "Text Library : wrong text ID '%d'", id);
|
||||
return _cache[id];
|
||||
}
|
||||
@@ -32,7 +32,7 @@ namespace mlx
|
||||
MLX_PROFILE_FUNCTION();
|
||||
auto it = std::find_if(_cache.begin(), _cache.end(), [&](const std::pair<TextID, std::shared_ptr<Text>>& v)
|
||||
{
|
||||
return v.second->getText() == text->getText() && std::find(_invalid_ids.begin(), _invalid_ids.end(), v.first) == _invalid_ids.end();
|
||||
return v.second->getText() == text->getText() && v.second->getColor() == text->getColor();
|
||||
});
|
||||
if(it != _cache.end())
|
||||
return it->first;
|
||||
@@ -44,23 +44,20 @@ namespace mlx
|
||||
void TextLibrary::removeTextFromLibrary(TextID id)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
if(!_cache.count(id) || std::find(_invalid_ids.begin(), _invalid_ids.end(), id) != _invalid_ids.end())
|
||||
if(!_cache.count(id))
|
||||
{
|
||||
core::error::report(e_kind::warning, "Text Library : trying to remove a text with an unkown or invalid ID '%d'", id);
|
||||
return;
|
||||
}
|
||||
_cache[id]->destroy();
|
||||
_invalid_ids.push_back(id);
|
||||
_cache.erase(id);
|
||||
}
|
||||
|
||||
void TextLibrary::clearLibrary()
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
for(auto& [id, text] : _cache)
|
||||
{
|
||||
text->destroy();
|
||||
_invalid_ids.push_back(id);
|
||||
}
|
||||
_cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/10 11:52:30 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/16 08:54:15 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/03/25 16:04:47 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <renderer/buffers/vk_ibo.h>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <mlx_profile.h>
|
||||
#include <renderer/texts/font.h>
|
||||
@@ -46,7 +45,6 @@ namespace mlx
|
||||
|
||||
private:
|
||||
std::unordered_map<TextID, std::shared_ptr<class Text>> _cache;
|
||||
std::vector<TextID> _invalid_ids;
|
||||
TextID _current_id = 1;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user