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> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/10/04 17:55:21 by maldavid #+# #+# */
|
/* 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;
|
void* img;
|
||||||
} mlx_t;
|
} mlx_t;
|
||||||
|
|
||||||
void* img = NULL;
|
//void* img = NULL;
|
||||||
|
|
||||||
int update(void* param)
|
int update(void* param)
|
||||||
{
|
{
|
||||||
@@ -32,13 +32,13 @@ int update(void* param)
|
|||||||
|
|
||||||
if(i == 200)
|
if(i == 200)
|
||||||
mlx_clear_window(mlx->mlx, mlx->win);
|
mlx_clear_window(mlx->mlx, mlx->win);
|
||||||
|
/*
|
||||||
if(img)
|
if(img)
|
||||||
mlx_destroy_image(mlx->mlx,img);
|
mlx_destroy_image(mlx->mlx,img);
|
||||||
img = mlx_new_image(mlx->mlx, 800, 800);
|
img = mlx_new_image(mlx->mlx, 800, 800);
|
||||||
mlx_set_image_pixel(mlx->mlx, img, 4, 4, 0xFF00FF00);
|
mlx_set_image_pixel(mlx->mlx, img, 4, 4, 0xFF00FF00);
|
||||||
mlx_put_image_to_window(mlx->mlx, mlx->win, img, 0, 0);
|
mlx_put_image_to_window(mlx->mlx, mlx->win, img, 0, 0);
|
||||||
|
*/
|
||||||
if(i >= 250)
|
if(i >= 250)
|
||||||
mlx_set_font_scale(mlx->mlx, mlx->win, "default", 16.f);
|
mlx_set_font_scale(mlx->mlx, mlx->win, "default", 16.f);
|
||||||
else
|
else
|
||||||
@@ -157,7 +157,11 @@ int main(void)
|
|||||||
mlx_put_image_to_window(mlx.mlx, mlx.win, mlx.logo_png, 10, 190);
|
mlx_put_image_to_window(mlx.mlx, mlx.win, mlx.logo_png, 10, 190);
|
||||||
|
|
||||||
mlx.img = create_image(&mlx);
|
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_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");
|
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> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/10/20 02:13:03 by maldavid #+# #+# */
|
/* 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:
|
private:
|
||||||
VmaAllocator _allocator;
|
VmaAllocator _allocator;
|
||||||
std::uint32_t _active_buffers_allocations = 0;
|
std::int32_t _active_buffers_allocations = 0;
|
||||||
std::uint32_t _active_images_allocations = 0;
|
std::int32_t _active_images_allocations = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/01/11 00:11:56 by maldavid #+# #+# */
|
/* 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
|
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();
|
MLX_PROFILE_FUNCTION();
|
||||||
if(_is_init)
|
if(_is_init)
|
||||||
return;
|
return;
|
||||||
_text = std::move(text);
|
_text = std::move(text);
|
||||||
|
_color = color;
|
||||||
_font = font;
|
_font = font;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
std::string debug_name = _text;
|
std::string debug_name = _text;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/01/11 00:09:04 by maldavid #+# #+# */
|
/* 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:
|
public:
|
||||||
Text() = default;
|
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;
|
void bind(class Renderer& renderer) noexcept;
|
||||||
inline FontID getFontInUse() const noexcept { return _font; }
|
inline FontID getFontInUse() const noexcept { return _font; }
|
||||||
void updateVertexData(int frame, std::vector<Vertex> vbo_data);
|
void updateVertexData(int frame, std::vector<Vertex> vbo_data);
|
||||||
inline std::uint32_t getIBOsize() noexcept { return _ibo.getSize(); }
|
inline std::uint32_t getIBOsize() noexcept { return _ibo.getSize(); }
|
||||||
inline const std::string& getText() const { return _text; }
|
inline const std::string& getText() const { return _text; }
|
||||||
|
inline std::uint32_t getColor() const noexcept { return _color; }
|
||||||
void destroy() noexcept;
|
void destroy() noexcept;
|
||||||
|
|
||||||
~Text();
|
~Text();
|
||||||
@@ -41,6 +42,7 @@ namespace mlx
|
|||||||
std::array<D_VBO, MAX_FRAMES_IN_FLIGHT> _vbo;
|
std::array<D_VBO, MAX_FRAMES_IN_FLIGHT> _vbo;
|
||||||
C_IBO _ibo;
|
C_IBO _ibo;
|
||||||
std::string _text;
|
std::string _text;
|
||||||
|
std::uint32_t _color;
|
||||||
FontID _font = nullfont;
|
FontID _font = nullfont;
|
||||||
bool _is_init = false;
|
bool _is_init = false;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/01/11 00:23:11 by maldavid #+# #+# */
|
/* 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>();
|
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);
|
id = TextLibrary::get().addTextToLibrary(text_data);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/04/10 11:59:57 by maldavid #+# #+# */
|
/* 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)
|
std::shared_ptr<Text> TextLibrary::getTextData(TextID id)
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
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);
|
core::error::report(e_kind::fatal_error, "Text Library : wrong text ID '%d'", id);
|
||||||
return _cache[id];
|
return _cache[id];
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ namespace mlx
|
|||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
auto it = std::find_if(_cache.begin(), _cache.end(), [&](const std::pair<TextID, std::shared_ptr<Text>>& v)
|
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())
|
if(it != _cache.end())
|
||||||
return it->first;
|
return it->first;
|
||||||
@@ -44,23 +44,20 @@ namespace mlx
|
|||||||
void TextLibrary::removeTextFromLibrary(TextID id)
|
void TextLibrary::removeTextFromLibrary(TextID id)
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
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);
|
core::error::report(e_kind::warning, "Text Library : trying to remove a text with an unkown or invalid ID '%d'", id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_cache[id]->destroy();
|
_cache[id]->destroy();
|
||||||
_invalid_ids.push_back(id);
|
_cache.erase(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextLibrary::clearLibrary()
|
void TextLibrary::clearLibrary()
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
for(auto& [id, text] : _cache)
|
for(auto& [id, text] : _cache)
|
||||||
{
|
|
||||||
text->destroy();
|
text->destroy();
|
||||||
_invalid_ids.push_back(id);
|
|
||||||
}
|
|
||||||
_cache.clear();
|
_cache.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/04/10 11:52:30 by maldavid #+# #+# */
|
/* 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 <renderer/buffers/vk_ibo.h>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <mlx_profile.h>
|
#include <mlx_profile.h>
|
||||||
#include <renderer/texts/font.h>
|
#include <renderer/texts/font.h>
|
||||||
@@ -46,7 +45,6 @@ namespace mlx
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_map<TextID, std::shared_ptr<class Text>> _cache;
|
std::unordered_map<TextID, std::shared_ptr<class Text>> _cache;
|
||||||
std::vector<TextID> _invalid_ids;
|
|
||||||
TextID _current_id = 1;
|
TextID _current_id = 1;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user