BR: Version::getOpenGLVersion() is broken (from OpenGLHelpers.cpp)

Hi there,

The below function appears to be broken as it is incorrectly translating the result from glGetString(GL_VERSION).

On an iOS 15 iPad Pro, the result is:
OpenGL ES 3.0 Metal - 94.5

So, then the way the function is written, it returns a version equivalent to:
juce::Version{ 0, 0 }

As far as I can see, the develop branch hasn’t changed this function either.
Please let me know if the problem is actually on my side and how I can fix it.

Cheers

static Version getOpenGLVersion()
{
    const auto* versionBegin = glGetString (GL_VERSION);

    if (versionBegin == nullptr)
        return {};

    const auto* versionEnd = findNullTerminator (versionBegin);
    const std::string versionString (versionBegin, versionEnd);
    const auto spaceSeparated = StringArray::fromTokens (versionString.c_str(), false);

    if (spaceSeparated.isEmpty())
        return {};

    const auto pointSeparated = StringArray::fromTokens (spaceSeparated[0], ".", "");

    const auto major = pointSeparated[0].getIntValue();
    const auto minor = pointSeparated[1].getIntValue();

    return { major, minor };
}

That’s annoying, it looks like this string isn’t in the specified format on iOS. The Khronos docs say:

The GL_VERSION and GL_SHADING_LANGUAGE_VERSION strings begin with a version number. The version number uses one of these forms:

major_number.minor_number major_number.minor_number.release_number

Vendor-specific information may follow the version number. Its format depends on the implementation, but a space always separates the version number and the vendor-specific information.

I’ll add in a workaround for iOS devices and update this thread once it’s on develop.

1 Like

ah, classic.
Thanks for your attention @reuk

That change has been made here:

Please update and let us know if you run into any further problems.