How to solve crash when linking library using OpenGL?

Hi everyone,

Currently I’m trying to use the Google Filament PBR renderer together with JUCE (MacOS 10.15).

For this, I set up a Projucer OpenGL project (which compiles fine). It stops working however when I link the released libraries from Filament (1.14.1), specifically the bluegl one. So a clean project, no code added, and I only add bluegl to the external libraries to link in the Projucer, and point it to the right location obviously.

The program compiles fine, but JUCE then crashes on:

return String::fromUTF8 ((const char*) glGetString (GL_SHADING_LANGUAGE_VERSION))

It seems as if JUCE and Filament are interacting, likely in the OpenGL functions. Would anyone know of a solution to this? Build issues aren’t my strongest point and I’ve been tearing my hairs out so far. Many thanks in advance!

Looks to me like, for whatever reason, the bluegl library is declaring its own symbols with the same names as the OpenGL function symbols. The versions in bluegl start off initialized to nullptr.

When we try to call a GL function in JUCE, we end up calling the uninitialised bluegl functions.

I suspect if there’s a way of initialising bluegl before JUCE tries to call any GL functions, then it might be possible to get things working that way. Unfortunately, the bluegl headers aren’t included in the filament distribution so I don’t have an easy way of testing this theory. You may need to read the filament code a bit to work out which public function initialises the OpenGL function pointers, and then call that function immediately after your app starts, before it tries to render anything.