mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
i dont know chat i did i was high as f*ck
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/11 22:06:09 by kbz_8 #+# #+# */
|
||||
/* Updated: 2024/01/11 01:23:20 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/01/16 09:11:26 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -19,7 +19,7 @@ constexpr const int RANGE = 1024;
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
Font::Font(Renderer& renderer, const std::filesystem::path& path, float scale) : non_copyable(), _name(path.string()), _scale(scale)
|
||||
Font::Font(Renderer& renderer, const std::filesystem::path& path, float scale) : _name(path.string()), _scale(scale)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
std::vector<uint8_t> tmp_bitmap(RANGE * RANGE);
|
||||
@@ -56,7 +56,7 @@ namespace mlx
|
||||
_atlas.setDescriptor(renderer.getFragDescriptorSet().duplicate());
|
||||
}
|
||||
|
||||
Font::Font(class Renderer& renderer, const std::string& name, const std::vector<uint8_t>& ttf_data, float scale) : non_copyable(), _name(name), _scale(scale)
|
||||
Font::Font(class Renderer& renderer, const std::string& name, const std::vector<uint8_t>& ttf_data, float scale) : _name(name), _scale(scale)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
std::vector<uint8_t> tmp_bitmap(RANGE * RANGE);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/11 21:17:04 by kbz_8 #+# #+# */
|
||||
/* Updated: 2024/01/11 20:08:55 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/01/16 09:14:53 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -15,13 +15,12 @@
|
||||
|
||||
#include <array>
|
||||
#include <stb_truetype.h>
|
||||
#include <utils/non_copyable.h>
|
||||
#include <renderer/images/texture_atlas.h>
|
||||
#include <utils/combine_hash.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
class Font : public non_copyable
|
||||
class Font
|
||||
{
|
||||
public:
|
||||
Font() = delete;
|
||||
@@ -32,7 +31,7 @@ namespace mlx
|
||||
inline const std::array<stbtt_packedchar, 96>& getCharData() const { return _cdata; }
|
||||
inline const TextureAtlas& getAtlas() const noexcept { return _atlas; }
|
||||
inline bool operator==(const Font& rhs) const { return rhs._name == _name && rhs._scale == _scale; }
|
||||
inline bool operator!=(const Font& rhs) const { return rhs._name != _name && rhs._scale != _scale; }
|
||||
inline bool operator!=(const Font& rhs) const { return rhs._name != _name || rhs._scale != _scale; }
|
||||
~Font();
|
||||
|
||||
private:
|
||||
@@ -43,18 +42,4 @@ namespace mlx
|
||||
};
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <>
|
||||
struct hash<mlx::Font>
|
||||
{
|
||||
std::size_t operator()(const mlx::Font& f) const noexcept
|
||||
{
|
||||
std::size_t hash = 0;
|
||||
mlx::hashCombine(hash, f.getName(), f.getScale());
|
||||
return hash;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/10 11:59:57 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/11 05:19:24 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/01/16 08:54:22 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <iostream>
|
||||
#include <renderer/texts/text_library.h>
|
||||
#include <renderer/texts/text.h>
|
||||
#include <core/errors.h>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/10 11:52:30 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/11 05:08:04 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/01/16 08:54:15 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
|
||||
#include <renderer/buffers/vk_vbo.h>
|
||||
#include <renderer/buffers/vk_ibo.h>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/06 16:41:13 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/11 04:54:16 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/01/17 03:47:46 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -14,28 +14,34 @@
|
||||
#include <renderer/texts/text_library.h>
|
||||
#include <renderer/texts/text.h>
|
||||
#include <renderer/texts/text_manager.h>
|
||||
#include <array>
|
||||
#include <core/profiler.h>
|
||||
#include <fstream>
|
||||
|
||||
#include <utils/dogica_ttf.h>
|
||||
#include <cstdio>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
void TextManager::init(Renderer& renderer) noexcept
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
_font_in_use = &const_cast<Font&>(*_font_set.emplace(renderer, "default", dogica_ttf, 6.0f).first);
|
||||
loadFont(renderer, "default", 6.f);
|
||||
}
|
||||
|
||||
void TextManager::loadFont(Renderer& renderer, const std::filesystem::path& filepath, float scale)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
if(filepath.string() == "default") // we're sure it is already loaded
|
||||
_font_in_use = &const_cast<Font&>(*_font_set.emplace(renderer, "default", dogica_ttf, scale).first);
|
||||
for(Font& font : _font_set)
|
||||
{
|
||||
if(filepath == font.getName() && scale == font.getScale())
|
||||
{
|
||||
_font_in_use = &font;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(filepath.string() == "default")
|
||||
_font_in_use = &_font_set.emplace_back(renderer, "default", dogica_ttf, scale);
|
||||
else
|
||||
_font_in_use = &const_cast<Font&>(*_font_set.emplace(renderer, filepath, scale).first);
|
||||
_font_in_use = &_font_set.emplace_back(renderer, filepath, scale);
|
||||
}
|
||||
|
||||
std::pair<DrawableResource*, bool> TextManager::registerText(int x, int y, uint32_t color, std::string str)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/06 16:24:11 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/11 18:48:01 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/01/16 09:04:05 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <stb_truetype.h>
|
||||
#include <cstdint>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
#include <mlx_profile.h>
|
||||
#include <renderer/texts/text_descriptor.h>
|
||||
#include <renderer/texts/text_library.h>
|
||||
@@ -40,7 +41,7 @@ namespace mlx
|
||||
|
||||
private:
|
||||
std::unordered_set<TextDrawDescriptor> _text_descriptors;
|
||||
std::unordered_set<Font> _font_set;
|
||||
std::vector<Font> _font_set;
|
||||
Font* _font_in_use = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user