Setting OpenGL version to 4.1 asserts a GL Error when trying to load shaders and textures

Hey yall,

I’m trying to set my Mac build to OpenGL 4.1 as it defaults to 2.1.
Everything works fine when using OpenGLContext::setOpenGLVersionRequired (OpenGLVersion) however, when I try to load shaders and textures I keep getting this assertion/error message:

***** GL_INVALID_ENUM at C:\Users\10850K\Documents\JUCE 7\JUCE 7.04\JUCE\modules\juce_opengl\opengl\juce_OpenGLTexture.cpp : 54

Not very descriptive but hey. I do NOT have this issue when on 2.1, or on 4.6 (Windows).
I am able to recreate the problem on Windows by setting the version to 4.1 as well.
Worth noting, the assertion is not critical in the sense I can just skip it and everything runs seemingly fine.

And for how I’m setting the textures, its nothing special

  for (auto j = 0; j < shader->getTextures().size(); ++j)
  {
      auto& tex = shader->getTextures().getReference(j);
      openGLContext->extensions.glActiveTexture(GL_TEXTURE0);
      glEnable(GL_TEXTURE_2D);
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      tex->bind();
      if (tex->getWidth() == 0 || tex->getHeight() == 0)
          tex->loadImage(shader->getTextureImages().getUnchecked(j));

      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
  }

In this call
tex->loadImage(shader->getTextureImages().getUnchecked(j));
The function gets to the create line, and then hits a GLError

Hopefully this is an issue on my end, but if not is there a way I can turn off this assertion ?
Thanks

This is invalid in a context using the Core Profile. There’s a few places in JUCE where we’re making that mistake, so I’ll fix those next week.

2 Likes

We’ve added a fix for this issue here:

1 Like

Lets go! Thank you so much