athanggupte / ApexGameEngine

Apex Game Engine
MIT License
4 stars 1 forks source link

Text Rendering in scene #32

Closed athanggupte closed 2 years ago

athanggupte commented 2 years ago

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:

  1. Wrapper class Apex::FontAtlas over ImFontAtlas
  2. Wrapper class Apex::FontGlyph over ImGlyph
  3. Create OpenGLTexture2D and set data from ImFontAtlas->GetTexDataAsRGBA32. Set this in ImFontAtlas->SetTexID()
  4. Functions Renderer2D::DrawGlyph() which should take in an Apex::FontGlyph and sets the quad attributes accordingly { position, color, UVs, texture index }
  5. Helper function Renderer2D::DrawText() which takes in a string and adds all the glyphs in it using similar method as in Renderer2D::DrawGlyph()

Reference links:

athanggupte commented 2 years ago

Implemented in 41e091837f62166fa4c5be6a335df04c9605152c