working text pipeline

This commit is contained in:
2023-04-11 13:21:11 +02:00
parent 599f1007ab
commit 098622c6b9
9 changed files with 217 additions and 96 deletions

66
src/renderer/text_library.h git.filemode.normal_file
View File

@@ -0,0 +1,66 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* text_library.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/10 11:52:30 by maldavid #+# #+# */
/* Updated: 2023/04/11 12:28:08 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __MLX_TEXT_LIBRARY__
#define __MLX_TEXT_LIBRARY__
#include <renderer/buffers/vk_vbo.h>
#include <renderer/buffers/vk_ibo.h>
#include <string>
#include <unordered_map>
#include <memory>
#include <vector>
#include <cstdint>
namespace mlx
{
using TextID = uint32_t;
constexpr TextID nulltext = 0;
class TextData
{
public:
TextData() = default;
void init(std::vector<Vertex> vbo_data, std::vector<uint16_t> ibo_data);
void bind(class Renderer& renderer) noexcept;
inline uint32_t getIBOsize() noexcept { return _ibo.getSize(); }
void destroy() noexcept;
~TextData() = default;
private:
C_VBO _vbo;
C_IBO _ibo;
};
class TextLibrary
{
public:
TextLibrary() = default;
std::shared_ptr<TextData> getTextData(TextID id);
TextID addTextToLibrary(std::shared_ptr<TextData> text);
void removeTextFromLibrary(TextID id);
void clearLibrary();
~TextLibrary() = default;
private:
std::unordered_map<TextID, std::shared_ptr<TextData>> _cache;
TextID _current_id = 1;
};
}
#endif