Class: Engine::Components::UISpriteRenderer

Inherits:
Engine::Component show all
Defined in:
lib/engine/components/ui_sprite_renderer.rb

Instance Attribute Summary collapse

Attributes inherited from Engine::Component

#game_object

Instance Method Summary collapse

Methods inherited from Engine::Component

#_erase!, #destroy, #destroy!, #destroyed?, destroyed_components, erase_destroyed_components, method_added, #renderer?, #set_game_object

Constructor Details

#initialize(tl, tr, br, bl, material) ⇒ UISpriteRenderer

Returns a new instance of UISpriteRenderer.



11
12
13
14
15
16
17
# File 'lib/engine/components/ui_sprite_renderer.rb', line 11

def initialize(tl, tr, br, bl, material)
  @v1 = tl
  @v2 = tr
  @v3 = br
  @v4 = bl
  @material = material
end

Instance Attribute Details

#materialObject (readonly)

Returns the value of attribute material.



5
6
7
# File 'lib/engine/components/ui_sprite_renderer.rb', line 5

def material
  @material
end

#v1Object (readonly)

Returns the value of attribute v1.



5
6
7
# File 'lib/engine/components/ui_sprite_renderer.rb', line 5

def v1
  @v1
end

#v2Object (readonly)

Returns the value of attribute v2.



5
6
7
# File 'lib/engine/components/ui_sprite_renderer.rb', line 5

def v2
  @v2
end

#v3Object (readonly)

Returns the value of attribute v3.



5
6
7
# File 'lib/engine/components/ui_sprite_renderer.rb', line 5

def v3
  @v3
end

#v4Object (readonly)

Returns the value of attribute v4.



5
6
7
# File 'lib/engine/components/ui_sprite_renderer.rb', line 5

def v4
  @v4
end

Instance Method Details

#startObject



19
20
21
22
23
# File 'lib/engine/components/ui_sprite_renderer.rb', line 19

def start
  setup_vertex_attribute_buffer
  setup_vertex_buffer
  setup_index_buffer
end

#ui_renderer?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/engine/components/ui_sprite_renderer.rb', line 7

def ui_renderer?
  true
end

#update(delta_time) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/engine/components/ui_sprite_renderer.rb', line 25

def update(delta_time)
  GL.BindVertexArray(@vao)
  GL.BindBuffer(GL::ELEMENT_ARRAY_BUFFER, @ebo)

  set_material_per_frame_data

  GL.DrawElements(GL::TRIANGLES, 6, GL::UNSIGNED_INT, 0)

  GL.BindVertexArray(0)
  GL.BindBuffer(GL::ELEMENT_ARRAY_BUFFER, 0)
end