I already have working code that sends raw data to godot in gdextension. Now I would like to send raw data of current frame (_process method) in c++ gdextension to other process …
I tried to do different things, but it seems like I cannot do it, for example
Viewport* viewport = get_viewport();
if (viewport) {
// Get the current frame's texture from the viewport
auto tex = viewport->get_texture();
auto image = viewport->get_image();
if (image.is_valid()) {
const uint8_t* data = image->get_data().read().ptr();
auto w = image->get_width();
auto h = image->get_height();
UtilityFunctions::print(w, "", h );
}
}
Maybe this was working on previous versions. Is there any documentation on how can I do it now? I’m extending Node2D to get _process method called for every frame.
I can confirm that it works for me. Printing the data pointer in UtilityFunctions prints . I don’t know enough about the project to know if _process is the best place to get the image.
The image class does have a few methods that may be useful, like save_png and save_png_to_buffer. Accessing the pointer directly, outside of the Godot process, may not end well.
I get a build error when I try to build with a class that hasn’t had their header set properly. You may want to include <godot/classes/image.hpp> as well.