Class: Engine::Components::FontRendererBase
- Inherits:
-
Engine::Component
- Object
- Engine::Component
- Engine::Components::FontRendererBase
- Defined in:
- lib/engine/components/renderers/font_renderer_base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#mesh ⇒ Object
readonly
Returns the value of attribute mesh.
-
#texture ⇒ Object
readonly
Returns the value of attribute texture.
Attributes inherited from Engine::Component
Instance Method Summary collapse
Methods inherited from Engine::Component
#_erase!, #destroy, #destroy!, #destroyed?, destroyed_components, erase_destroyed_components, method_added, #renderer?, #set_game_object, #ui_renderer?, #update
Methods included from Serializable
allowed_class?, get_class, included, register_class, #uuid
Instance Attribute Details
#mesh ⇒ Object (readonly)
Returns the value of attribute mesh.
7 8 9 |
# File 'lib/engine/components/renderers/font_renderer_base.rb', line 7 def mesh @mesh end |
#texture ⇒ Object (readonly)
Returns the value of attribute texture.
7 8 9 |
# File 'lib/engine/components/renderers/font_renderer_base.rb', line 7 def texture @texture end |
Instance Method Details
#awake ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/engine/components/renderers/font_renderer_base.rb', line 9 def awake # Original vertex order for ear-clipping, UVs flipped for Y-down camera @mesh = Engine::PolygonMesh.new( [Vector[-0.5, 0.5], Vector[0.5, 0.5], Vector[0.5, -0.5], Vector[-0.5, -0.5]], [[0, 1], [1, 1], [1, 0], [0, 0]] ) @texture = @font.texture.texture end |
#draw ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/engine/components/renderers/font_renderer_base.rb', line 30 def draw shader.use Engine::GL.BindVertexArray(@vao) Engine::GL.BindBuffer(Engine::GL::ELEMENT_ARRAY_BUFFER, @ebo) set_shader_per_frame_data Engine::GL.DrawElementsInstanced(Engine::GL::TRIANGLES, mesh.index_data.length, Engine::GL::UNSIGNED_INT, 0, @string.length) end |
#start ⇒ Object
18 19 20 21 22 23 |
# File 'lib/engine/components/renderers/font_renderer_base.rb', line 18 def start setup_vertex_attribute_buffer setup_vertex_buffer setup_index_buffer Engine::GL.BindVertexArray(0) end |
#update_string(string) ⇒ Object
25 26 27 28 |
# File 'lib/engine/components/renderers/font_renderer_base.rb', line 25 def update_string(string) @string = string update_vbo_buf end |