diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-05-04 20:37:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-04 20:37:51 +0200 |
commit | 38a922a36501bdc34eb73df7c70083940d75a689 (patch) | |
tree | 00355a109d004258c9092c24e61aa42b2398c395 /doc/classes/Viewport.xml | |
parent | 84f64ddde956f5ecba4674750442df89b75556c9 (diff) | |
parent | 708a3b3db82650a9657d0f8f7c2e4d4fb02ca32e (diff) |
Merge pull request #60740 from KoBeWi/postapo_frame_draw
Diffstat (limited to 'doc/classes/Viewport.xml')
-rw-r--r-- | doc/classes/Viewport.xml | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml index ce466b2d0f..148c6d7064 100644 --- a/doc/classes/Viewport.xml +++ b/doc/classes/Viewport.xml @@ -75,17 +75,12 @@ <return type="ViewportTexture" /> <description> Returns the viewport's texture. - [b]Note:[/b] Due to the way OpenGL works, the resulting [ViewportTexture] is flipped vertically. You can use [method Image.flip_y] on the result of [method Texture2D.get_image] to flip it back, for example: - [codeblocks] - [gdscript] - var img = get_viewport().get_texture().get_image() - img.flip_y() - [/gdscript] - [csharp] - Image img = GetViewport().GetTexture().GetImage(); - img.FlipY(); - [/csharp] - [/codeblocks] + [b]Note:[/b] When trying to store the current texture (e.g. in a file), it might be completely black or outdated if used too early, especially when used in e.g. [method Node._ready]. To make sure the texture you get is correct, you can await [signal RenderingServer.frame_post_draw] signal. + [codeblock] + func _ready(): + await RenderingServer.frame_post_draw + $Viewport.get_texture().get_image().save_png("user://Screenshot.png") + [/codeblock] </description> </method> <method name="get_viewport_rid" qualifiers="const"> |