Class: Mittsu::OpenGLLightRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/mittsu/renderers/opengl/opengl_light_renderer.rb

Constant Summary collapse

LIGHT_CLASSES =
[
  AmbientLight,
  DirectionalLight,
  PointLight,
  SpotLight,
  HemisphereLight
]
LIGHT_TYPES =
LIGHT_CLASSES.map { |klass| klass::TYPE }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(renderer) ⇒ OpenGLLightRenderer

Returns a new instance of OpenGLLightRenderer.



14
15
16
17
18
19
20
21
# File 'lib/mittsu/renderers/opengl/opengl_light_renderer.rb', line 14

def initialize(renderer)
  @renderer = renderer
  @lights_need_update = true
  @cache = {}
  LIGHT_CLASSES.each { |klass|
    @cache[klass::TYPE] = klass::Cache.new
  }
end

Instance Attribute Details

#cacheObject

Returns the value of attribute cache.



3
4
5
# File 'lib/mittsu/renderers/opengl/opengl_light_renderer.rb', line 3

def cache
  @cache
end

#lights_need_updateObject

Returns the value of attribute lights_need_update.



3
4
5
# File 'lib/mittsu/renderers/opengl/opengl_light_renderer.rb', line 3

def lights_need_update
  @lights_need_update
end

Instance Method Details

#resetObject



39
40
41
# File 'lib/mittsu/renderers/opengl/opengl_light_renderer.rb', line 39

def reset
  @lights_need_update = true
end

#setup(lights) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/mittsu/renderers/opengl/opengl_light_renderer.rb', line 23

def setup(lights)
  @cache.values.each(&:reset)

  lights.each do |light|
    next if light.only_shadow
    light.setup(self)
  end

  LIGHT_CLASSES.each do |klass|
    cache = @cache[klass::TYPE]
    klass.null_remaining_lights(cache)
  end

  @lights_need_update = false
end