adding std namespace to all libstd provided primitive types

This commit is contained in:
2024-02-25 08:04:44 +01:00
parent 828024e131
commit 3624caf519
61 changed files with 193 additions and 189 deletions

View File

@@ -24,7 +24,7 @@ namespace mlx
_build_data = path;
}
Font::Font(class Renderer& renderer, const std::string& name, const std::vector<uint8_t>& ttf_data, float scale) : _name(name), _renderer(renderer), _scale(scale)
Font::Font(class Renderer& renderer, const std::string& name, const std::vector<std::uint8_t>& ttf_data, float scale) : _name(name), _renderer(renderer), _scale(scale)
{
_build_data = ttf_data;
}
@@ -32,7 +32,7 @@ namespace mlx
void Font::buildFont()
{
MLX_PROFILE_FUNCTION();
std::vector<uint8_t> file_bytes;
std::vector<std::uint8_t> file_bytes;
if(std::holds_alternative<std::filesystem::path>(_build_data))
{
std::ifstream file(std::get<std::filesystem::path>(_build_data), std::ios::binary);
@@ -48,14 +48,14 @@ namespace mlx
file.close();
}
std::vector<uint8_t> tmp_bitmap(RANGE * RANGE);
std::vector<uint8_t> vulkan_bitmap(RANGE * RANGE * 4);
std::vector<std::uint8_t> tmp_bitmap(RANGE * RANGE);
std::vector<std::uint8_t> vulkan_bitmap(RANGE * RANGE * 4);
stbtt_pack_context pc;
stbtt_PackBegin(&pc, tmp_bitmap.data(), RANGE, RANGE, RANGE, 1, nullptr);
if(std::holds_alternative<std::filesystem::path>(_build_data))
stbtt_PackFontRange(&pc, file_bytes.data(), 0, _scale, 32, 96, _cdata.data());
else
stbtt_PackFontRange(&pc, std::get<std::vector<uint8_t>>(_build_data).data(), 0, _scale, 32, 96, _cdata.data());
stbtt_PackFontRange(&pc, std::get<std::vector<std::uint8_t>>(_build_data).data(), 0, _scale, 32, 96, _cdata.data());
stbtt_PackEnd(&pc);
for(int i = 0, j = 0; i < RANGE * RANGE; i++, j += 4)
{

View File

@@ -27,7 +27,7 @@ namespace mlx
public:
Font() = delete;
Font(class Renderer& renderer, const std::filesystem::path& path, float scale);
Font(class Renderer& renderer, const std::string& name, const std::vector<uint8_t>& ttf_data, float scale);
Font(class Renderer& renderer, const std::string& name, const std::vector<std::uint8_t>& ttf_data, float scale);
inline const std::string& getName() const { return _name; }
inline float getScale() const noexcept { return _scale; }
@@ -45,7 +45,7 @@ namespace mlx
private:
std::array<stbtt_packedchar, 96> _cdata;
TextureAtlas _atlas;
std::variant<std::filesystem::path, std::vector<uint8_t>> _build_data;
std::variant<std::filesystem::path, std::vector<std::uint8_t>> _build_data;
std::string _name;
class Renderer& _renderer;
float _scale = 0;

View File

@@ -24,7 +24,7 @@
namespace mlx
{
using FontID = uint32_t;
using FontID = std::uint32_t;
constexpr FontID nullfont = 0;
class FontLibrary : public Singleton<FontLibrary>

View File

@@ -16,7 +16,7 @@
namespace mlx
{
void Text::init(std::string text, FontID font, std::vector<Vertex> vbo_data, std::vector<uint16_t> ibo_data)
void Text::init(std::string text, FontID font, std::vector<Vertex> vbo_data, std::vector<std::uint16_t> ibo_data)
{
MLX_PROFILE_FUNCTION();
_text = std::move(text);
@@ -30,11 +30,11 @@ namespace mlx
}
for(int i = 0; i < MAX_FRAMES_IN_FLIGHT; i++)
_vbo[i].create(sizeof(Vertex) * vbo_data.size(), static_cast<const void*>(vbo_data.data()), debug_name.c_str());
_ibo.create(sizeof(uint16_t) * ibo_data.size(), ibo_data.data(), debug_name.c_str());
_ibo.create(sizeof(std::uint16_t) * ibo_data.size(), ibo_data.data(), debug_name.c_str());
#else
for(int i = 0; i < MAX_FRAMES_IN_FLIGHT; i++)
_vbo[i].create(sizeof(Vertex) * vbo_data.size(), static_cast<const void*>(vbo_data.data()), nullptr);
_ibo.create(sizeof(uint16_t) * ibo_data.size(), ibo_data.data(), nullptr);
_ibo.create(sizeof(std::uint16_t) * ibo_data.size(), ibo_data.data(), nullptr);
#endif
}

View File

@@ -27,11 +27,11 @@ namespace mlx
public:
Text() = default;
void init(std::string text, FontID font, std::vector<Vertex> vbo_data, std::vector<uint16_t> ibo_data);
void init(std::string text, FontID font, 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 uint32_t getIBOsize() noexcept { return _ibo.getSize(); }
inline std::uint32_t getIBOsize() noexcept { return _ibo.getSize(); }
inline const std::string& getText() const { return _text; }
void destroy() noexcept;

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/11 00:23:11 by maldavid #+# #+# */
/* Updated: 2024/01/18 09:44:54 by maldavid ### ########.fr */
/* Updated: 2024/02/25 07:58:21 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -30,14 +30,14 @@ constexpr const int RANGE = 1024;
namespace mlx
{
TextDrawDescriptor::TextDrawDescriptor(std::string text, uint32_t _color, int _x, int _y) : color(_color), x(_x), y(_y), _text(std::move(text))
TextDrawDescriptor::TextDrawDescriptor(std::string text, std::uint32_t _color, int _x, int _y) : color(_color), x(_x), y(_y), _text(std::move(text))
{}
void TextDrawDescriptor::init(FontID font) noexcept
{
MLX_PROFILE_FUNCTION();
std::vector<Vertex> vertexData;
std::vector<uint16_t> indexData;
std::vector<std::uint16_t> indexData;
float stb_x = 0.0f;
float stb_y = 0.0f;

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/11 00:13:34 by maldavid #+# #+# */
/* Updated: 2024/01/18 09:40:06 by maldavid ### ########.fr */
/* Updated: 2024/02/25 07:58:13 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -30,12 +30,12 @@ namespace mlx
public:
TextID id;
uint32_t color;
std::uint32_t color;
int x;
int y;
public:
TextDrawDescriptor(std::string text, uint32_t _color, int _x, int _y);
TextDrawDescriptor(std::string text, std::uint32_t _color, int _x, int _y);
void init(FontID font) noexcept;
bool operator==(const TextDrawDescriptor& rhs) const { return _text == rhs._text && x == rhs.x && y == rhs.y && color == rhs.color; }

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/10 11:59:57 by maldavid #+# #+# */
/* Updated: 2024/01/18 08:02:31 by maldavid ### ########.fr */
/* Updated: 2024/02/24 21:38:11 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -16,6 +16,7 @@
#include <renderer/renderer.h>
#include <algorithm>
#include <core/profiler.h>
#include <iostream>
namespace mlx
{
@@ -49,6 +50,7 @@ namespace mlx
core::error::report(e_kind::warning, "Text Library : trying to remove a text with an unkown or invalid ID '%d'", id);
return;
}
std::cout << _cache[id]->getText() << std::endl;
_cache[id]->destroy();
_invalid_ids.push_back(id);
}

View File

@@ -26,7 +26,7 @@
namespace mlx
{
using TextID = uint32_t;
using TextID = std::uint32_t;
constexpr TextID nulltext = 0;
class TextLibrary : public Singleton<TextLibrary>

View File

@@ -6,10 +6,11 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/06 16:41:13 by maldavid #+# #+# */
/* Updated: 2024/01/18 09:45:24 by maldavid ### ########.fr */
/* Updated: 2024/02/24 21:39:12 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#include <iostream>
#include <renderer/texts/text_descriptor.h>
#include <renderer/texts/text_library.h>
#include <renderer/texts/text.h>
@@ -38,7 +39,7 @@ namespace mlx
_font_in_use = FontLibrary::get().addFontToLibrary(font);
}
std::pair<DrawableResource*, bool> TextManager::registerText(int x, int y, uint32_t color, std::string str)
std::pair<DrawableResource*, bool> TextManager::registerText(int x, int y, std::uint32_t color, std::string str)
{
MLX_PROFILE_FUNCTION();
auto res = _text_descriptors.emplace(std::move(str), color, x, y);
@@ -52,6 +53,7 @@ namespace mlx
if(_font_in_use != text_ptr->getFontInUse())
{
// TODO : update text vertex buffers rather than destroying it and recreating it
std::cout << "test" << std::endl;
TextLibrary::get().removeTextFromLibrary(res.first->id);
const_cast<TextDrawDescriptor&>(*res.first).init(_font_in_use);
}

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/06 16:24:11 by maldavid #+# #+# */
/* Updated: 2024/01/18 13:52:01 by maldavid ### ########.fr */
/* Updated: 2024/02/25 07:58:36 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -34,8 +34,8 @@ namespace mlx
TextManager() = default;
void init(Renderer& renderer) noexcept;
std::pair<DrawableResource*, bool> registerText(int x, int y, uint32_t color, std::string str);
inline void clear() { _text_descriptors.clear(); TextLibrary::get().clearLibrary(); }
std::pair<DrawableResource*, bool> registerText(int x, int y, std::uint32_t color, std::string str);
inline void clear() { _text_descriptors.clear(); }
void loadFont(Renderer& renderer, const std::filesystem::path& filepath, float scale);
void destroy() noexcept;