Class: EhbGameLib::Window::GlReadPixelsImage

Inherits:
Object
  • Object
show all
Defined in:
lib/ehb_game_lib/window.rb

Constant Summary collapse

DEPTH =
4

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y, width, height) ⇒ GlReadPixelsImage

Returns a new instance of GlReadPixelsImage.



57
58
59
60
61
62
63
64
# File 'lib/ehb_game_lib/window.rb', line 57

def initialize(x, y, width, height)
  @columns = width
  @rows = height
  Gosu.flush
  Gosu.gl do
    @blob = ::Gl.glReadPixels(x, y, width, height, Gl::GL_RGBA, Gl::GL_UNSIGNED_BYTE)
  end
end

Instance Attribute Details

#columnsObject (readonly)

Returns the value of attribute columns.



53
54
55
# File 'lib/ehb_game_lib/window.rb', line 53

def columns
  @columns
end

#rowsObject (readonly)

Returns the value of attribute rows.



53
54
55
# File 'lib/ehb_game_lib/window.rb', line 53

def rows
  @rows
end

Instance Method Details

#to_blobObject



66
67
68
# File 'lib/ehb_game_lib/window.rb', line 66

def to_blob
  @blob.force_encoding('binary').scan(/.{#{columns * 4}}/m).reverse.join
end