Class: Gosu::Window

Inherits:
Object
  • Object
show all
Defined in:
lib/devil/gosu.rb

Overview

monkey patches for Gosu::Window class

Instance Method Summary (collapse)

Instance Method Details

- (Object) screenshot

return a screenshot of the framebuffer as a Devil::Image. This method is only available if require 'devil/gosu' is used



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/devil/gosu.rb', line 37

def screenshot
    require 'opengl'

    img = nil
    self.gl do
        data = glReadPixels(0, 0, self.width, self.height, GL_RGBA, GL_UNSIGNED_BYTE)
        img = Devil.from_blob(data, self.width, self.height)
    end
    
    img
end