Class: Stagecraft::Renderer::Stats
- Inherits:
-
Object
- Object
- Stagecraft::Renderer::Stats
- Defined in:
- lib/stagecraft/renderer/stats.rb
Constant Summary collapse
- COUNTERS =
%i[draw_calls triangles buffers textures pipelines visible_objects culled_objects].freeze
Instance Method Summary collapse
- #decrement(counter, amount = 1) ⇒ Object
- #increment(counter, amount = 1) ⇒ Object
-
#initialize ⇒ Stats
constructor
A new instance of Stats.
- #reset_frame! ⇒ Object
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
Instance Method Details
#decrement(counter, amount = 1) ⇒ Object
28 29 30 |
# File 'lib/stagecraft/renderer/stats.rb', line 28 def decrement(counter, amount = 1) increment(counter, -amount) end |
#increment(counter, amount = 1) ⇒ Object
22 23 24 25 26 |
# File 'lib/stagecraft/renderer/stats.rb', line 22 def increment(counter, amount = 1) raise ArgumentError, "unknown stats counter #{counter.inspect}" unless COUNTERS.include?(counter) instance_variable_set(:"@#{counter}", public_send(counter) + amount) end |
#reset_frame! ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/stagecraft/renderer/stats.rb', line 14 def reset_frame! @draw_calls = 0 @triangles = 0 @visible_objects = 0 @culled_objects = 0 self end |
#to_h ⇒ Object
32 33 34 |
# File 'lib/stagecraft/renderer/stats.rb', line 32 def to_h COUNTERS.to_h { |counter| [counter, public_send(counter)] } end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/stagecraft/renderer/stats.rb', line 36 def to_s to_h.map { |name, value| "#{name}=#{value}" }.join(" ") end |