Class: Rugl::Resources::Renderbuffer
- Defined in:
- lib/rugl/resources/renderbuffer.rb
Constant Summary collapse
- FORMAT_MAP =
{ depth_component24: :DEPTH_COMPONENT24, depth24_stencil8: :DEPTH24_STENCIL8, rgba8: :RGBA8 }.freeze
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Attributes inherited from Base
Instance Method Summary collapse
- #bind ⇒ Object
- #destroy ⇒ Object
-
#initialize(context, opts) ⇒ Renderbuffer
constructor
A new instance of Renderbuffer.
- #resize(width, height) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(context, opts) ⇒ Renderbuffer
Returns a new instance of Renderbuffer.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rugl/resources/renderbuffer.rb', line 14 def initialize(context, opts) super(context) @width = opts.fetch(:width).to_i @height = opts.fetch(:height).to_i @format = opts.fetch(:format, :depth_component24).to_sym @target = gl_const(:RENDERBUFFER) @id = allocate_gl_id(:GenRenderbuffers) bind allocate_storage(@width, @height) end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
12 13 14 |
# File 'lib/rugl/resources/renderbuffer.rb', line 12 def format @format end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
12 13 14 |
# File 'lib/rugl/resources/renderbuffer.rb', line 12 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
12 13 14 |
# File 'lib/rugl/resources/renderbuffer.rb', line 12 def width @width end |
Instance Method Details
#bind ⇒ Object
26 27 28 29 30 |
# File 'lib/rugl/resources/renderbuffer.rb', line 26 def bind ensure_alive! gl_call(:BindRenderbuffer, @target, @id) self end |
#destroy ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/rugl/resources/renderbuffer.rb', line 41 def destroy return if destroyed? delete_gl_id(:DeleteRenderbuffers, @id) mark_destroyed! nil end |
#resize(width, height) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/rugl/resources/renderbuffer.rb', line 32 def resize(width, height) ensure_alive! @width = width.to_i @height = height.to_i bind allocate_storage(@width, @height) self end |