2015-04-12 23:58:05 +02:00
|
|
|
|
|
|
|
extends Control
|
|
|
|
|
|
|
|
|
|
|
|
func _on_button_pressed():
|
|
|
|
get_viewport().queue_screen_capture()
|
2015-11-21 13:31:25 +01: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 23:58:05 +02:00
|
|
|
var img = get_viewport().get_screen_capture()
|
2015-11-21 13:31:25 +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-11-21 13:31:25 +01:00
|
|
|
# Set it to the capture node
|
2015-04-12 23:58:05 +02:00
|
|
|
get_node("capture").set_texture(tex)
|