Skip to content

Commit b548a84

Browse files
authored
Merge pull request #460 from EludeQ/viewports-frame_post_draw
Update Viewports tutorial to use "frame_post_draw"
2 parents 57baf0a + 7a9b45f commit b548a84

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

viewport/screen_capture/screen_capture.gd

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ onready var captured_image = $CapturedImage
44

55
func _on_CaptureButton_pressed():
66
get_viewport().set_clear_mode(Viewport.CLEAR_MODE_ONLY_NEXT_FRAME)
7-
# Let two frames pass to make sure the screen was captured.
8-
yield(get_tree(), "idle_frame")
9-
yield(get_tree(), "idle_frame")
7+
# Wait until the frame has finished before getting the texture.
8+
yield(VisualServer, "frame_post_draw")
109

1110
# Retrieve the captured image.
1211
var img = get_viewport().get_texture().get_data()

0 commit comments

Comments
 (0)