Sha256: 8c5684eecad28f3847e2678ec9291c72b1b769371950be836aeafc7ff04d252a

Contents?: true

Size: 878 Bytes

Versions: 2

Compression:

Stored size: 878 Bytes

Contents

module Mittsu
  class OpenGL::LightRenderer
    attr_accessor :lights_need_update, :cache

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

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

    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

    def reset
      @lights_need_update = true
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mittsu-opengl-0.5.1 lib/mittsu/opengl/light_renderer.rb
mittsu-opengl-0.5.0 lib/mittsu/opengl/light_renderer.rb