mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-04 06:09:46 +03:00
Update Viewports tutorial to use "frame_post_draw"
This commit is contained in:
@@ -4,9 +4,8 @@ onready var captured_image = $CapturedImage
|
||||
|
||||
func _on_CaptureButton_pressed():
|
||||
get_viewport().set_clear_mode(Viewport.CLEAR_MODE_ONLY_NEXT_FRAME)
|
||||
# Let two frames pass to make sure the screen was captured.
|
||||
yield(get_tree(), "idle_frame")
|
||||
yield(get_tree(), "idle_frame")
|
||||
# Wait until the frame has finished before getting the texture.
|
||||
yield(VisualServer, "frame_post_draw")
|
||||
|
||||
# Retrieve the captured image.
|
||||
var img = get_viewport().get_texture().get_data()
|
||||
|
||||
Reference in New Issue
Block a user