Class: Roglew::Texture2d

Inherits:
Object
  • Object
show all
Defined in:
lib/roglew/texture2d.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handle) ⇒ Texture2d

Returns a new instance of Texture2d.



7
8
9
10
11
# File 'lib/roglew/texture2d.rb', line 7

def initialize(handle)
  @handle = handle
  @id = handle.bind { |context| context.gen_textures }
  ObjectSpace.define_finalizer(self, self.class.finalize(@handle, @id))
end

Instance Attribute Details

#handleObject (readonly)

Returns the value of attribute handle.



5
6
7
# File 'lib/roglew/texture2d.rb', line 5

def handle
  @handle
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/roglew/texture2d.rb', line 5

def id
  @id
end

Class Method Details

.finalize(handle, id) ⇒ Object



13
14
15
16
17
18
# File 'lib/roglew/texture2d.rb', line 13

def self.finalize(handle, id)
  proc do
    #puts "releasing texture #{id}"
    handle.delete_textures [id]
  end
end

Instance Method Details

#bind(level = 0, deferred = nil, &block) ⇒ Object



20
21
22
# File 'lib/roglew/texture2d.rb', line 20

def bind(level = 0, deferred = nil, &block)
  create_binding(deferred, GL::TEXTURE_2D, level, &block)
end