Embedding a Ruby interpreter in a C++ app

前端 未结 5 1086
半阙折子戏
半阙折子戏 2020-12-08 08:56

I\'m hoping to use Ruby as a scripting language for my game engine. I\'ve found the usual articles describing how to call Ruby classes from C++ code and vice versa (e.g. her

5条回答
  •  感动是毒
    2020-12-08 09:02

    You're on the right track. The key is to do something similar to the section on Embedding Concepts in the link you posted. In simple terms it's little more than:

    ruby_init();
    ruby_script("some_script");
    

    You may need to copy over all the #ifdef stuff from main.c to get everything working. From then it's a matter of building an API to your C++ functions you want to expose, and depending on your design, multi-threading the thing.

提交回复
热议问题