Closed DND-dou closed 3 years ago
All GDNative functionality is implemented in Godot itself, in the modules/gdnative folder. You can use it because those functions are defined in the Godot executable, both editor and export templates/exported games.
For example, godot_vector2_get_x
is implemented here.
@gilzoide Oh!!!! Your answer is very helpful to me!!! Thanks a bundle!!!!
But I still have a little doubt: When I use godotC library, I will use godot gdnative core api struct like :
godot_ gdnative_ core_ api_ struct* API;
...
API->godot_vector2_get_x(...);
Now I know godot vector2 getx() is defined in Godot. But how does godot vector2_ getx get into godot gdnative core api_ struct?
I found godot_ gdnative_core_api_struct in godot/modules/gdnative/gdnative.cpp https://github.com/godotengine/godot/blob/4fcc5891450a7dca9c8ebae6ff3765f5f060c442/modules/gdnative/gdnative.cpp
on line 49
// Defined in gdnative_api_struct.gen.cpp
extern const godot_gdnative_core_api_struct api_struct;
The problem is that I can't find gdnative api struct.gen.cpp !!! It still bothers me,Could you help me please? (X﹏X)
I think I found out where gdnative_api_struct.gen.cpp is !
I find godot/modules/gdnative/gdnative_builders.py https://github.com/godotengine/godot/blob/8f7f5846397297fff6e8a08f89bc60ce658699cc/modules/gdnative/gdnative_builders.py
So gdnative_ api_struct.gen.cpp appears when the engine is compiled Am I right?
So gdnative_ api_struct.gen.cpp appears when the engine is compiled
That's right! =]
@gilzoide Thank you very much (・∀・) . Now I finally know the mechanism of godoC library!!!
I've been using the godotC library for a while, and most of the time, it works. However,I have some doubts, because I found that godotC library only includes '.h' files. I want to know where the function definition is. Then I found that some of the function definitions are in the gdnative module like
godot/modules/gdnative/gdnative/variant.cpp
But I also found some strange things. For example, there are some functions that I can't find in the gdnative module!!! (/゚Д゚)/First
I can't find the definition of godot_vector2_get_x() in the
godot_headers/.../vector2.h
file But I can use it!!! WHY? w(゚Д゚)wSecond
in transform2d.h,I want to get the x property of transform2d,But I didn't find godot_transform2d_get_x() HOW can I get x? (´?ω?`)
If you know the answer, please let me know. Thanks (=゚ω゚)ノ