mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Merge pull request #60740 from KoBeWi/postapo_frame_draw
This commit is contained in:
commit
38a922a365
1 changed files with 6 additions and 11 deletions
|
|
@ -75,17 +75,12 @@
|
||||||
<return type="ViewportTexture" />
|
<return type="ViewportTexture" />
|
||||||
<description>
|
<description>
|
||||||
Returns the viewport's texture.
|
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:
|
[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.
|
||||||
[codeblocks]
|
[codeblock]
|
||||||
[gdscript]
|
func _ready():
|
||||||
var img = get_viewport().get_texture().get_image()
|
await RenderingServer.frame_post_draw
|
||||||
img.flip_y()
|
$Viewport.get_texture().get_image().save_png("user://Screenshot.png")
|
||||||
[/gdscript]
|
[/codeblock]
|
||||||
[csharp]
|
|
||||||
Image img = GetViewport().GetTexture().GetImage();
|
|
||||||
img.FlipY();
|
|
||||||
[/csharp]
|
|
||||||
[/codeblocks]
|
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_viewport_rid" qualifiers="const">
|
<method name="get_viewport_rid" qualifiers="const">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue