Class: Rugl::Resources::Framebuffer
- Defined in:
- lib/rugl/resources/framebuffer.rb
Instance Attribute Summary collapse
-
#color_attachment ⇒ Object
readonly
Returns the value of attribute color_attachment.
-
#depth_attachment ⇒ Object
readonly
Returns the value of attribute depth_attachment.
-
#depth_stencil_attachment ⇒ Object
readonly
Returns the value of attribute depth_stencil_attachment.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#stencil_attachment ⇒ Object
readonly
Returns the value of attribute stencil_attachment.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Attributes inherited from Base
Instance Method Summary collapse
- #bind ⇒ Object
- #destroy ⇒ Object
-
#initialize(context, opts) ⇒ Framebuffer
constructor
A new instance of Framebuffer.
- #resize(width, height) ⇒ Object
- #unbind ⇒ Object
- #use ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(context, opts) ⇒ Framebuffer
Returns a new instance of Framebuffer.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rugl/resources/framebuffer.rb', line 8 def initialize(context, opts) super(context) @width = opts.fetch(:width).to_i @height = opts.fetch(:height).to_i @target = gl_const(:FRAMEBUFFER) = [] @id = allocate_gl_id(:GenFramebuffers) begin bind (opts.fetch(:color, true)) setup_depth_and_stencil(opts) validate_complete! unbind rescue StandardError cleanup_failed_initialization raise end end |
Instance Attribute Details
#color_attachment ⇒ Object (readonly)
Returns the value of attribute color_attachment.
6 7 8 |
# File 'lib/rugl/resources/framebuffer.rb', line 6 def end |
#depth_attachment ⇒ Object (readonly)
Returns the value of attribute depth_attachment.
6 7 8 |
# File 'lib/rugl/resources/framebuffer.rb', line 6 def end |
#depth_stencil_attachment ⇒ Object (readonly)
Returns the value of attribute depth_stencil_attachment.
6 7 8 |
# File 'lib/rugl/resources/framebuffer.rb', line 6 def end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
6 7 8 |
# File 'lib/rugl/resources/framebuffer.rb', line 6 def height @height end |
#stencil_attachment ⇒ Object (readonly)
Returns the value of attribute stencil_attachment.
6 7 8 |
# File 'lib/rugl/resources/framebuffer.rb', line 6 def end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
6 7 8 |
# File 'lib/rugl/resources/framebuffer.rb', line 6 def width @width end |
Instance Method Details
#bind ⇒ Object
28 29 30 31 32 |
# File 'lib/rugl/resources/framebuffer.rb', line 28 def bind ensure_alive! gl_call(:BindFramebuffer, @target, @id) self end |
#destroy ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/rugl/resources/framebuffer.rb', line 68 def destroy return if destroyed? delete_gl_id(:DeleteFramebuffers, @id) .each(&:destroy) mark_destroyed! nil end |
#resize(width, height) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rugl/resources/framebuffer.rb', line 52 def resize(width, height) ensure_alive! @width = width.to_i @height = height.to_i [, , , ].compact.each do || .resize(@width, @height) if .respond_to?(:resize) end bind reattach_all validate_complete! unbind self end |
#unbind ⇒ Object
34 35 36 37 38 |
# File 'lib/rugl/resources/framebuffer.rb', line 34 def unbind return unless gl_supports?(:BindFramebuffer) gl_call(:BindFramebuffer, @target, 0) end |
#use ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rugl/resources/framebuffer.rb', line 40 def use ensure_alive! bind return self unless block_given? begin yield self ensure unbind end end |