Class: Rendering::RenderTexture
- Inherits:
-
Object
- Object
- Rendering::RenderTexture
- Defined in:
- lib/engine/rendering/render_texture.rb
Instance Attribute Summary collapse
-
#color_textures ⇒ Object
readonly
Returns the value of attribute color_textures.
-
#depth_stencil_texture ⇒ Object
(also: #depth_texture)
readonly
Returns the value of attribute depth_stencil_texture.
-
#framebuffer ⇒ Object
readonly
Returns the value of attribute framebuffer.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #bind ⇒ Object
- #color_texture ⇒ Object
-
#initialize(width, height, num_color_attachments: 1) ⇒ RenderTexture
constructor
A new instance of RenderTexture.
-
#normal_texture ⇒ Object
Accessor for normal+roughness texture (second attachment).
- #resize(width, height) ⇒ Object
Constructor Details
#initialize(width, height, num_color_attachments: 1) ⇒ RenderTexture
Returns a new instance of RenderTexture.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/engine/rendering/render_texture.rb', line 7 def initialize(width, height, num_color_attachments: 1) @width = width @height = height = @color_textures = [] create_framebuffer create_color_textures create_depth_stencil_texture attach_to_framebuffer check_framebuffer_complete end |
Instance Attribute Details
#color_textures ⇒ Object (readonly)
Returns the value of attribute color_textures.
5 6 7 |
# File 'lib/engine/rendering/render_texture.rb', line 5 def color_textures @color_textures end |
#depth_stencil_texture ⇒ Object (readonly) Also known as: depth_texture
Returns the value of attribute depth_stencil_texture.
5 6 7 |
# File 'lib/engine/rendering/render_texture.rb', line 5 def depth_stencil_texture @depth_stencil_texture end |
#framebuffer ⇒ Object (readonly)
Returns the value of attribute framebuffer.
5 6 7 |
# File 'lib/engine/rendering/render_texture.rb', line 5 def framebuffer @framebuffer end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
5 6 7 |
# File 'lib/engine/rendering/render_texture.rb', line 5 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
5 6 7 |
# File 'lib/engine/rendering/render_texture.rb', line 5 def width @width end |
Instance Method Details
#bind ⇒ Object
31 32 33 34 |
# File 'lib/engine/rendering/render_texture.rb', line 31 def bind Engine::GL.BindFramebuffer(Engine::GL::FRAMEBUFFER, @framebuffer) Engine::GL.Viewport(0, 0, @width, @height) end |
#color_texture ⇒ Object
19 20 21 |
# File 'lib/engine/rendering/render_texture.rb', line 19 def color_texture @color_textures[0] end |
#normal_texture ⇒ Object
Accessor for normal+roughness texture (second attachment)
24 25 26 |
# File 'lib/engine/rendering/render_texture.rb', line 24 def normal_texture @color_textures[1] end |
#resize(width, height) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/engine/rendering/render_texture.rb', line 36 def resize(width, height) return if width == @width && height == @height @width = width @height = height @color_textures.each do |tex| Engine::GL.BindTexture(Engine::GL::TEXTURE_2D, tex) Engine::GL.TexImage2D(Engine::GL::TEXTURE_2D, 0, Engine::GL::RGBA16F, @width, @height, 0, Engine::GL::RGBA, Engine::GL::FLOAT, nil) end Engine::GL.BindTexture(Engine::GL::TEXTURE_2D, @depth_stencil_texture) Engine::GL.TexImage2D(Engine::GL::TEXTURE_2D, 0, Engine::GL::DEPTH24_STENCIL8, @width, @height, 0, Engine::GL::DEPTH_STENCIL, Engine::GL::UNSIGNED_INT_24_8, nil) end |