Class: Engine::Components::UI::SpriteRenderer
- Inherits:
-
Engine::Component
- Object
- Engine::Component
- Engine::Components::UI::SpriteRenderer
- Defined in:
- lib/engine/components/ui/sprite_renderer.rb
Instance Attribute Summary collapse
-
#material ⇒ Object
readonly
Returns the value of attribute material.
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, #update
Methods included from Serializable
allowed_class?, #awake, get_class, included, register_class, #uuid
Instance Attribute Details
#material ⇒ Object (readonly)
Returns the value of attribute material.
8 9 10 |
# File 'lib/engine/components/ui/sprite_renderer.rb', line 8 def material @material end |
Instance Method Details
#draw ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/engine/components/ui/sprite_renderer.rb', line 24 def draw rect = @ui_rect.computed_rect Engine::GL.BindVertexArray(@vao) Engine::GL.BindBuffer(Engine::GL::ELEMENT_ARRAY_BUFFER, @ebo) update_vertex_buffer(rect) set_material_per_frame_data Engine::GL.DrawElements(Engine::GL::TRIANGLES, 6, Engine::GL::UNSIGNED_INT, 0) end |
#start ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/engine/components/ui/sprite_renderer.rb', line 14 def start @ui_rect = game_object.component(UI::Rect) raise "UI::SpriteRenderer requires a UI::Rect component on the same GameObject" unless @ui_rect setup_vertex_attribute_buffer setup_index_buffer setup_vertex_buffer Engine::GL.BindVertexArray(0) end |
#ui_renderer? ⇒ Boolean
10 11 12 |
# File 'lib/engine/components/ui/sprite_renderer.rb', line 10 def ui_renderer? true end |