Sol2 ImGui Bindings

July, 2020

Sol2 ImGui Bindings are ImGui Bindings specifically created for Sol2 which is a sort of Lua Binding library to bind C++ code functions to Lua which makes it possible to have back-end C++ functionality that can be called in Lua scripts.

Used Skills

Development Process

  • Why?

    I wanted to experiment with Lua and C++ and decided on using Sol2, but there were no ImGui bindings available so I decided to create them myself as the perfect opportunity to learn more about everything.

  • Sol2 and ImGui

    I had to work out how Sol2 worked and ImGui as I needed to create the wrapper between them. I had to convert every ImGui function (where possible) to a function that could be used in Lua. Luckily, Lua did support multiple return values which helped solve many ImGui functions that used reference variables.

Struggles

Converting functions

The hardest part was converting the ImGui functions to something usable in Lua. I had to go over every single one and see what was necessary to return again to also give as parameter (due to no pointers in Lua). I also had to bypass some functions by returning Lua tables or giving Lua tables as parameters.