0 votes

Hi!
I am trying out a feature for my 2D game where the users are shown a screenshot of their playthrough after the level is finished or on the game over screen.

I am capturing the texture from the viewport with..

get_viewport().set_clear_mode(old_clear_mode)

However, I am struggling to understand how I would go about adding a logo to the texture.

How would I go about doing this?

FYI the function that is taking the screenshot:

func capture_screen():
get_viewport().set_clear_mode(Viewport.CLEAR_MODE_ONLY_NEXT_FRAME)
    # Wait until the frame has finished before getting the texture.
    yield(VisualServer, "frame_post_draw")

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

    # Flip it on the y-axis (because it's flipped).
    img.flip_y()

    captured = true
Godot version 3.3
in Engine by (12 points)

Capture with your logo in form of Sprite/TextureRect on top of your scene?

1 Answer

0 votes

Hi.
just use

blit_rect ( Image src, Rect2 src_rect, Vector2 dst )

-

# Retrieve the captured image.
img = get_viewport().get_texture().get_data()
# Flip it on the y-axis (because it's flipped).
img.flip_y()
img.blit_rect( my_logo_image, my_logo_image.get_used_rect( ) , Vector2(10,10) )

https://docs.godotengine.org/en/stable/classes/class_image.html#class-image-method-blit-rect

by (3,932 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.