top of page

Runtime recompiled c++

perforce-icon@3.125x.png
icons8-c++-100.png

During this project I focussed on the following:

  • C++ Scripting

  • DLL

  • Doxygen​

  • SFML

The video above shows the concept very well. I have an empty scene and an empty script. During the video, I populate the script and recompile the script multiple times without closing the main application. The recompiled script gets reloaded and the changes can be seen immediately. 

C++ Scripting

Conceptually the c++ scripting is fairly easy to understand. Load and reload a dynamic library with scripts in it. However, during implementation, I found that there are some hurdles to overcome.

Handles

The safest thing to do is expose only handles to the scripts as these are easy to serialize and we can internally play with memory positions without having to track all pointers and update them. This was very handy for the scripts as I needed to be able to save them and load them again. Internally Handles are just indices to lists.

Each object I needed to expose to the scripts has such a Handle.

Interface

The script uses free functions to interface with the engine. These functions use the Handle to change the correct object. For example the SpriteComponent:

SpriteComponent.h
SpriteComponent.cpp

As you can see I have used Doxygen extensively to document my interfaces.

Icons by Icons8

  • envelope (1)
  • White LinkedIn Icon
bottom of page