]> gitweb.factorcode.org Git - factor.git/commitdiff
cap: make sure to use GL context of world being screenshot.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 11 Jan 2018 22:16:58 +0000 (14:16 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 11 Jan 2018 22:16:58 +0000 (14:16 -0800)
extra/cap/cap.factor

index 1949f533c5fc0cd005e61b78b6501654cc6c7f2e..9f633455b71a3d616d62ade8b6dd7b6d2c04916e 100644 (file)
@@ -1,9 +1,8 @@
 ! Copyright (C) 2008 Doug Coleman, Joe Groff.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.syntax arrays byte-arrays fry images
-images.normalization images.viewer kernel math math.vectors
-models namespaces opengl opengl.gl sequences ui ui.gadgets
-ui.gadgets.worlds ;
+USING: accessors byte-arrays images images.normalization
+images.viewer kernel math namespaces opengl opengl.gl sequences
+ui ui.backend ui.gadgets.worlds ;
 IN: cap
 
 <PRIVATE
@@ -13,6 +12,7 @@ IN: cap
     [ gl-scale ] bi@ * >fixnum <byte-array> ;
 
 : gl-screenshot ( gadget -- byte-array )
+    [ find-world handle>> select-gl-context ]
     [
         [
             GL_BACK glReadBuffer
@@ -22,7 +22,7 @@ IN: cap
         dim>> first2 [ gl-scale >fixnum ] bi@
         GL_RGBA GL_UNSIGNED_BYTE
     ]
-    [ screenshot-array ] bi
+    [ screenshot-array ] tri
     [ glReadPixels ] keep ;
 
 PRIVATE>