2015-04-12 21:58:05 +00:00
|
|
|
|
|
|
|
extends Control
|
|
|
|
|
|
|
|
|
|
|
|
func _on_button_pressed():
|
|
|
|
get_viewport().queue_screen_capture()
|
2015-11-21 12:31:25 +00:00
|
|
|
# Let two frames pass to make sure the screen was captured
|
|
|
|
yield(get_tree(), "idle_frame")
|
|
|
|
yield(get_tree(), "idle_frame")
|
|
|
|
# Retrieve the captured image
|
2015-04-12 21:58:05 +00:00
|
|
|
var img = get_viewport().get_screen_capture()
|
2015-11-21 12:31:25 +00:00
|
|
|
# Create a texture for it
|
2015-04-12 21:58:05 +00:00
|
|
|
var tex = ImageTexture.new()
|
|
|
|
tex.create_from_image(img)
|
2015-11-21 12:31:25 +00:00
|
|
|
# Set it to the capture node
|
2015-04-12 21:58:05 +00:00
|
|
|
get_node("capture").set_texture(tex)
|