Godot: [3.0] viewport screen capture doesn't work

Created on 12 Apr 2017  ·  3Comments  ·  Source: godotengine/godot

Operating system or device - Godot version: Linux, Godot 3.0 (master)

Issue description:
Getting a screen capture from any viewport results in empty data.

Steps to reproduce:

get_viewport().queue_screen_capture()
yield(get_tree(),"idle_frame")
yield(get_tree(),"idle_frame")
var i = get_viewport().get_screen_capture()
i.save_png("user://cap.png")
bug rendering

Most helpful comment

@MarianoGnu you are correct, the issue is only that ViewportTexture::get_data() is not bound to GDScript, but that should be easy to solve.

All 3 comments

Now queue_screen_capture() and get_screen_capture() don't even exist.

Haven't tryed from gdscript, but you should be able to call 'viewport.get_texture().get_data()' to get a reference to Image wich you can save. Also calling 'image.lock()' and image.unlock()' should let you get (and maybe set?) pixels.

This is how it works for color picker when picking a color from the screen:
https://github.com/godotengine/godot/blob/master/scene/gui/color_picker.cpp#L428

@MarianoGnu you are correct, the issue is only that ViewportTexture::get_data() is not bound to GDScript, but that should be easy to solve.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Zephilinox picture Zephilinox  ·  3Comments

timoschwarzer picture timoschwarzer  ·  3Comments

Zylann picture Zylann  ·  3Comments

ducdetronquito picture ducdetronquito  ·  3Comments

Spooner picture Spooner  ·  3Comments