Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource::get_rid() is not exposed as a GDExtension virtual method #78127

Closed
DmitriySalnikov opened this issue Jun 11, 2023 · 4 comments
Closed

Comments

@DmitriySalnikov
Copy link
Contributor

Godot version

4.x

System information

Windows 10

Issue description

Resource::get_rid() is not exposed as GDExtension virtual method using GDVIRTUAL*.

For me, this makes it a bit difficult to create my own Texture2D and forces me to override the draw_* methods.
This issue has already been discussed here godotengine/godot-cpp#877, but for some reason it was archived.

Steps to reproduce

N/A

Minimal reproduction project

N/A

@AThousandShips
Copy link
Member

AThousandShips commented Jun 12, 2023

This is probably because in the bindings get_rid is not virtual, the virtual method is _get_rid but the extensions treats this as a hidden method I believe

It was archived because it was closed by the person who opened it, this is standard practice afik

@DmitriySalnikov
Copy link
Contributor Author

the virtual method is _get_rid but the extensions treats this as a hidden method I believe

This method simply does not exist, because GDVIRTUAL* was not used, as for example here

It was archived because it was closed by the person who opened it, this is standard practice afik

Yeah, but I didn't understand why that person decided to close it. 🤷‍♂️

@DmitriySalnikov
Copy link
Contributor Author

I found a message from reduz that it is impossible to use GDVIRTUAL here.

I also added Resource::get_rid() function as core, this should be added manually to Resource too because the binder does not allow me to use GDVIRTUAL for it due to include dependency

I also looked at the implementation of Resource::get_rid and there is a check for the existence of the _get_rid method in the scripts and some kind of get_rid call to GDExtension. But in GDExtension I found only a pointer with a similar name, which is not assigned any value anywhere.

godot/core/io/resource.cpp

Lines 306 to 323 in 37d1dfe

RID Resource::get_rid() const {
if (get_script_instance()) {
Callable::CallError ce;
RID ret = get_script_instance()->callp(SNAME("_get_rid"), nullptr, 0, ce);
if (ce.error == Callable::CallError::CALL_OK && ret.is_valid()) {
return ret;
}
}
if (_get_extension() && _get_extension()->get_rid) {
RID ret;
ret.from_uint64(_get_extension()->get_rid(_get_extension_instance()));
if (ret.is_valid()) {
return ret;
}
}
return RID();
}

But if I manually add the get_rid/_get_rid method and even bind it, then nothing works anyway and I still need to manually override the methods for drawing textures.

@dsnopek dsnopek added this to the 4.x milestone Jun 13, 2024
@raulsntos
Copy link
Member

@raulsntos raulsntos modified the milestones: 4.x, 4.4 Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants