Currently, text rendering can only be done in the ImGui context and not in the actual 3D scene. By stealing a few functions from the ImGui library we can directly incorporate font rendering into the Renderer2D.
Proposed architecture:
Wrapper class Apex::FontAtlas over ImFontAtlas
Wrapper class Apex::FontGlyph over ImGlyph
Create OpenGLTexture2D and set data from ImFontAtlas->GetTexDataAsRGBA32. Set this in ImFontAtlas->SetTexID()
Functions Renderer2D::DrawGlyph() which should take in an Apex::FontGlyph and sets the quad attributes accordingly { position, color, UVs, texture index }
Helper function Renderer2D::DrawText() which takes in a string and adds all the glyphs in it using similar method as in Renderer2D::DrawGlyph()
Currently, text rendering can only be done in the ImGui context and not in the actual 3D scene. By stealing a few functions from the ImGui library we can directly incorporate font rendering into the
Renderer2D
.Proposed architecture:
Apex::FontAtlas
overImFontAtlas
Apex::FontGlyph
overImGlyph
OpenGLTexture2D
and set data fromImFontAtlas->GetTexDataAsRGBA32
. Set this inImFontAtlas->SetTexID()
Renderer2D::DrawGlyph()
which should take in anApex::FontGlyph
and sets the quad attributes accordingly{ position, color, UVs, texture index }
Renderer2D::DrawText()
which takes in a string and adds all the glyphs in it using similar method as inRenderer2D::DrawGlyph()
Reference links: