Godot Version
4.4.1
Question
Trying to create a GDExtension extending TextureRect, I realized I was not even able to create a dummy red image using C++.
What I would like to reproduce (GDScript):
var image = Image.create(640, 360, false, Image.FORMAT_RGBA8)
image.fill(Color(1, 0, 0, 1))
print("img format: ",img.get_format())
print("img width: ",img.get_width())
print("img height: ",img.get_height())
Ouput:
img format: 5
img width: 100
img height: 100
My best guess so far to do the same thing in C++:
Ref<Image> img;
img.instantiate();
if (! img.is_null()) {
UtilityFunctions::print("Image instantiation OK");
}
img->create(640, 360, false, Image::FORMAT_RGBA8);
img->fill(Color(1.0, 0.0, 0.0, 1.0)); // RGBA
UtilityFunctions::print("img format: ", Variant(img->get_format()));
UtilityFunctions::print("img width: ", Variant(img->get_width()));
UtilityFunctions::print("img height: ", Variant(img->get_height()));
It compiles, runs without error, but fails to create the image:
Image instantiation OK
img format: 0
img width: 0
img height: 0
Is it a bug in Godot 4.4.1 or is it me that don’t use it correctly ?