2015-04-12 23:58:05 +02:00
|
|
|
|
|
|
|
extends Control
|
|
|
|
|
|
|
|
|
|
|
|
func _on_button_pressed():
|
|
|
|
get_viewport().queue_screen_capture()
|
2015-12-09 08:38:23 +01:00
|
|
|
# let two frames pass to make sure the screen was captured
|
2015-04-12 23:58:05 +02:00
|
|
|
yield(get_tree(),"idle_frame")
|
|
|
|
yield(get_tree(),"idle_frame")
|
2015-12-09 08:38:23 +01:00
|
|
|
# retrieve the captured image
|
2015-04-12 23:58:05 +02:00
|
|
|
var img = get_viewport().get_screen_capture()
|
2015-12-09 08:38:23 +01:00
|
|
|
# create a texture for it
|
2015-04-12 23:58:05 +02:00
|
|
|
var tex = ImageTexture.new()
|
|
|
|
tex.create_from_image(img)
|
2015-12-09 08:38:23 +01:00
|
|
|
# set it to the capture node
|
2015-04-12 23:58:05 +02:00
|
|
|
get_node("capture").set_texture(tex)
|