1 ! Copyright (C) 2008 Doug Coleman, Joe Groff.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors arrays byte-arrays kernel math namespaces
4 opengl.gl sequences math.vectors ui graphics.bitmap graphics.viewer
5 models ui.gadgets.worlds ui.gadgets fry alien.syntax ;
8 : screenshot-array ( world -- byte-array )
9 dim>> [ first 3 * 4 align ] [ second ] bi * <byte-array> ;
11 : gl-screenshot ( gadget -- byte-array )
14 GL_PACK_ALIGNMENT 4 glPixelStorei
17 [ dim>> first2 GL_BGR GL_UNSIGNED_BYTE ]
18 [ screenshot-array ] bi
19 [ glReadPixels ] keep ;
21 : screenshot ( window -- bitmap )
26 : save-screenshot ( window path -- )
27 [ screenshot ] dip save-bitmap ;
29 : screenshot. ( window -- )
30 [ screenshot <graphics-gadget> ] [ title>> ] bi open-window ;