JUCE OpenGL and projectM Library Initialization

I am having some problems with the JUCE OpenGlContext and the OpenGl context needed by libprojectM.

The libprojectM is a static 64 bit library compiled from the projectM repository on github. ProjectM is an implementation of the Milkdrop audio visualizer.

Everything is compiling and linking with no errors.

The documentation for projectM indicates that it is supposed to use the current active OpenGL context on the current thread. According to the debugger, it is all running on the same thread and JUCE has created an OpenGL context and made it active on the thread.

When debugging the standalone JUCE program in the event where the context is created, the context seems to be created but the projectm_create is failing in this JUCE code segment:

void projectMComponent::newOpenGLContextCreated()
{
// Attach new context to projectM
_projectM = projectm_create();
projectm_get_window_size(_projectM, &_width, &_height);
}

projectm_create() fails in the Texture initialization code when the code to generate the samplers is executed:

Sampler::Sampler(const GLint wrapMode, const GLint filterMode)
: m_wrapMode(wrapMode)
, m_filterMode(filterMode)
{
glGenSamplers(1, &m_samplerId);
glSamplerParameteri(m_samplerId, GL_TEXTURE_MIN_FILTER, filterMode);
glSamplerParameteri(m_samplerId, GL_TEXTURE_MAG_FILTER, filterMode);
glSamplerParameteri(m_samplerId, GL_TEXTURE_WRAP_S, wrapMode);
glSamplerParameteri(m_samplerId, GL_TEXTURE_WRAP_T, wrapMode);
}

The glGenSamplers call fails. This is the 1st OpenGl call, and I can’t trace into the call so I believe that the OpenGl context is not available to the libprojectM call.

I am not that familiar with OpenGL or with the use of static libraries called from JUCE.

Any assistance or pointers to additional information would be appreciated.

The table here shows that this function was introduced in OpenGL 3.3. It’s likely that your context is using an older GL version.

Maybe setting the GL version on the JUCE OpenGL context by calling setOpenGLVersionRequired() will help.

1 Like