Class: Rendering::ShadowMapArray
- Inherits:
-
Object
- Object
- Rendering::ShadowMapArray
- Defined in:
- lib/engine/rendering/shadow_map_array.rb
Instance Attribute Summary collapse
-
#depth_texture ⇒ Object
readonly
Returns the value of attribute depth_texture.
-
#framebuffer ⇒ Object
readonly
Returns the value of attribute framebuffer.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#layer_count ⇒ Object
readonly
Returns the value of attribute layer_count.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #bind_layer(layer_index) ⇒ Object
-
#initialize(width: 2048, height: 2048, layer_count: 4) ⇒ ShadowMapArray
constructor
A new instance of ShadowMapArray.
Constructor Details
#initialize(width: 2048, height: 2048, layer_count: 4) ⇒ ShadowMapArray
Returns a new instance of ShadowMapArray.
7 8 9 10 11 12 13 14 |
# File 'lib/engine/rendering/shadow_map_array.rb', line 7 def initialize(width: 2048, height: 2048, layer_count: 4) @width = width @height = height @layer_count = layer_count create_framebuffer create_depth_texture_array check_framebuffer_complete end |
Instance Attribute Details
#depth_texture ⇒ Object (readonly)
Returns the value of attribute depth_texture.
5 6 7 |
# File 'lib/engine/rendering/shadow_map_array.rb', line 5 def depth_texture @depth_texture end |
#framebuffer ⇒ Object (readonly)
Returns the value of attribute framebuffer.
5 6 7 |
# File 'lib/engine/rendering/shadow_map_array.rb', line 5 def framebuffer @framebuffer end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
5 6 7 |
# File 'lib/engine/rendering/shadow_map_array.rb', line 5 def height @height end |
#layer_count ⇒ Object (readonly)
Returns the value of attribute layer_count.
5 6 7 |
# File 'lib/engine/rendering/shadow_map_array.rb', line 5 def layer_count @layer_count end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
5 6 7 |
# File 'lib/engine/rendering/shadow_map_array.rb', line 5 def width @width end |
Instance Method Details
#bind_layer(layer_index) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/engine/rendering/shadow_map_array.rb', line 16 def bind_layer(layer_index) raise "Layer index #{layer_index} out of bounds (max: #{@layer_count - 1})" if layer_index >= @layer_count Engine::GL.BindFramebuffer(Engine::GL::FRAMEBUFFER, @framebuffer) Engine::GL.FramebufferTextureLayer(Engine::GL::FRAMEBUFFER, Engine::GL::DEPTH_ATTACHMENT, @depth_texture, 0, layer_index) Engine::GL.Viewport(0, 0, @width, @height) Engine::GL.Clear(Engine::GL::DEPTH_BUFFER_BIT) end |