0 votes

Hi,

I'm porting a hidden object game from Starling to Godot. In the game, I use screenshots quite a bit for transitions between levels.
I'm now looking at the Screen Capture tutorial for Godot 3.0, and I was wondering why this code :

var img = get_viewport().get_texture().get_data()
img.flip_y()

produces a screenshot that's smaller than the game screen ? Also, why is the image flipped by default ?

https://postimg.cc/d7rLxfD9

in Engine by (101 points)

I believe it's based on the size of the monitor. If you maximize the screen it gives a different result. Just what I found.

1 Answer

0 votes
Best answer

The screenshot isn't smaller than the game's viewport. The TextureRect node that shows the screenshot is scaled down 0.5.

The image data is flipped because the underlying rendering API, OpenGL, assumes y coordinates from bottom to top but Godot 2D features use Y coordinates from top to bottom. If you capture a screenshot from memory managed by OpenGL, you have to flip it so it matches Godot coordinates system.

by (150 points)
selected by

Thank you both for answering my question !

@hammeron : I totally overlooked the scaling property ... And thank you for your explanation on OpenGL ! I hate not knowing 'why' =)

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 Frequently asked questions and 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 [email protected] with your username.