I was just experimenting with adding a new function to godot/core/image.cpp to access through Javascript and thought it would be useful to document for others who needed new C++ methods accessible via Javascript (for perf or other reasons).
Write the implementation for the functions in the .cpp file
Updating the Image::_bind_methods() function with the new functions (easy to forget to to this, godot will compile, but you won't be able to access in JS without updating the bind_methods function).
Then recompile godot w/ the ECMAScript module.
I don't know if there are limitations to functions created this way (do return values need to be specific primitives?) and I don't know if other core apis always have a _bind_methods() function, but it would be helpful to add to the readme, wiki, or some other docs how to do this in a generic way.
I was just experimenting with adding a new function to
godot/core/image.cpp
to access through Javascript and thought it would be useful to document for others who needed new C++ methods accessible via Javascript (for perf or other reasons).I made a gist here: https://gist.github.com/Flux159/b602806d3941e530e87cf969400a7994 with notes, but the basics are as follows for image.cpp:
Then recompile godot w/ the ECMAScript module.
I don't know if there are limitations to functions created this way (do return values need to be specific primitives?) and I don't know if other core apis always have a _bind_methods() function, but it would be helpful to add to the readme, wiki, or some other docs how to do this in a generic way.