Defold + Raylib custom renderer integration

As many of you know already I’ve participated in the Defold + Yandex Games Game Jam. My entry is a 3D racing game

As a challenge to myself and because it’s fun I’ve decided to implement something that itched my brain for a while - integrate a custom renderer inside Defold as a native extension. It totally could be useful in real world projects for various reasons:

  • Port C++ games to Defold
  • Implement a high fidelity rendering pipeline
  • Add a few graphical eye-candies as a part of a regular Defold project

It works on HTML5 and macOS - my main targets for this game jam. It runs on Android but I am having some strange dt issue, the gameplay is slow but not choppy.
iOS - not tested, Windows - doesn’t compile, didn’t care, who wants to take a look?

Here is the source code

C++ part is in the native/ dir. Models are in resources/ dir.

Right now it renders instead of Defold renderer but still with a GUI on top. It’s also possible to render to a texture and display that on a quad within the Defold’s renderer, there is some leftover code about it. However due to some bug in Raylib regarding depth buffer there are visual artifacts if render to texture is used.

I had to substantially modify the sources of the raylib to make it compile within Defold so it’s not a drop in replacement when updating, most fixes can be ported to raylib and you would just need to specify correct lib options in its header file. That’s a task for real raylib enthusiasts though.

That’s it. I hope it can be useful.

26 Likes

I like the concept - I guess raylib is fairly straight C/C++ and thats why you used it?
Has me wondering about other ones like Filament :slight_smile:
Great work. I’ll hopefully get some time this weekend to have a look at it. Im loving some of these 3D projects people are doing.

3 Likes

Yes, straight C++ with a minimalistic wrapper around OpenGL to help with multiplatform. Thanks!

3 Likes