How to integrate exsiting C/C++ project in godot 2D?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By fastfading

How to integrate exsiting c++ project in godot 2D?
for some game already has some written code , rewrite it would be a huge task.
Since godot has plugin, how to use it with existing code.

This kind of project usually has a whole game logic ,and game loop like
loop {
DealwithInput
updateGame()
Draw()
}
we just want godot do the input , load texture and draw .
updateGame logic is in old code.
For the draw part, just need a node that display sprite each loop.
the sprite attribute like position is update in old c/c++ code

Does anyone has any idea how to do this ?

:bust_in_silhouette: Reply From: fastfading

There are many existing project , they may need this feature too.
redo everything from start , it is a big task

:bust_in_silhouette: Reply From: eons

Godot’s SceneTree manages the game loop (input, update, draw).

You can have a single Node in the tree that manages the data or port it to the Godot way and make many nodes for different tasks (in gdscript and gdnative if needed).

For a more tight integration, look if you can modify the engine and make your own MainLoop.

Check

And

in my opinion ,

make a node for the main game
run the old c logic code in an independent thread , make 2 pipe.
Pipe1 to get the input from godot.
Pipe2 to push the display sprite each frame to godot.
Godot just do rendering in this node.

For other menu, setting, ui etc, make other node, use the godot way.

Is it possible ?
And how to make this main game

fastfading | 2018-09-12 01:22