add bounding box for text drawable and add possibility to share data among different instances
This commit is contained in:
@@ -33,32 +33,42 @@ namespace OpenVulkano::Scene
|
||||
//bool sdfMultiChannel = false;
|
||||
};
|
||||
|
||||
struct AtlasData
|
||||
{
|
||||
std::map<uint32_t, GlyphInfo> glyphs;
|
||||
AtlasMetadata meta;
|
||||
std::unique_ptr<Image::Image> img;
|
||||
Texture texture;
|
||||
};
|
||||
|
||||
class TextDrawable : public SimpleDrawable
|
||||
{
|
||||
public:
|
||||
static Shader& GetSdfDefaultShader();
|
||||
static Shader& GetMsdfDefaultShader();
|
||||
TextDrawable(const TextConfig& config = TextConfig());
|
||||
TextDrawable(const Array<char>& atlasMetadata, const TextConfig& config = TextConfig());
|
||||
TextDrawable(const std::string& atlasMetadataFile, const TextConfig& config = TextConfig());
|
||||
TextDrawable(const std::string& atlasMetadataFile, Texture* atlasTex, const TextConfig& config = TextConfig());
|
||||
TextDrawable(const Array<char>& atlasMetadata, Texture* atlasTex, const TextConfig& config = TextConfig());
|
||||
TextDrawable(const std::map<uint32_t, GlyphInfo>& glyphData, Texture* atlasTex, const TextConfig& config = TextConfig());
|
||||
TextDrawable(const std::shared_ptr<AtlasData>& atlasData, const TextConfig& config = TextConfig());
|
||||
TextDrawable(IFontAtlasGenerator* fontAtlasGenerator, const TextConfig& config = TextConfig());
|
||||
void GenerateText(const std::string& text, const Math::Vector3f& pos = Math::Vector3f(0.f));
|
||||
void SetConfig(const TextConfig& cfg) { m_cfg = cfg; }
|
||||
void SetShader(Shader* shader) { m_shader = shader; }
|
||||
void SetAtlasData(const std::shared_ptr<AtlasData>& atlasData);
|
||||
Math::AABB& GetBoundingBox() { return m_bbox; }
|
||||
TextConfig& GetConfig() { return m_cfg; }
|
||||
Shader* GetShader() { return m_shader; }
|
||||
std::shared_ptr<AtlasData> GetAtlasData() { return m_atlasData; }
|
||||
void SetFontAtlasGenerator(IFontAtlasGenerator* fontAtlasGenerator);
|
||||
IFontAtlasGenerator* GetFontAtlasGenerator() { return m_fontAtlasGenerator; }
|
||||
private:
|
||||
Geometry m_geometry;
|
||||
Material m_material;
|
||||
UniformBuffer m_uniBuffer;
|
||||
std::map<uint32_t, GlyphInfo> m_glyphs;
|
||||
AtlasMetadata m_meta;
|
||||
std::unique_ptr<Image::Image> m_img;
|
||||
std::optional<Texture> m_texture;
|
||||
std::shared_ptr<AtlasData> m_atlasData;
|
||||
Math::AABB m_bbox;
|
||||
IFontAtlasGenerator* m_fontAtlasGenerator = nullptr;
|
||||
Shader* m_shader = nullptr;
|
||||
TextConfig m_cfg;
|
||||
|
||||
Reference in New Issue
Block a user