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.



63
64
65
66
67
68
69
70
# File 'lib/ehb_game_lib/window.rb', line 63

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.



59
60
61
# File 'lib/ehb_game_lib/window.rb', line 59

def columns
  @columns
end

#rowsObject (readonly)

Returns the value of attribute rows.



59
60
61
# File 'lib/ehb_game_lib/window.rb', line 59

def rows
  @rows
end

Instance Method Details

#to_blobObject



72
73
74
# File 'lib/ehb_game_lib/window.rb', line 72

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