Why does creating OpenGL ES 3.1 context failing on macOS?

712 views
Skip to first unread message

stir...@gmail.com

unread,
Feb 1, 2021, 1:53:03 AM2/1/21
to angleproject
I am working on macOS with angle. I compiled angle with angle branch `chromium/4402`, and wrote a demo trying to create  OpenGL ES 3.1 contex. But always failed on `eglCreateContext`. 
Is there some limitations about ES 3.1 on macOS? According to the README.md, macOS support of Desktop GL is complete. Since ES 3.1 support of Desktop GL backend is complete, macOS should support ES 3.1 already. Did I mistook this introduction?

The code as bellowing:

EGLDisplay display;
EGLSurface mSurface;
bool initializeGLContext(){
    // display
    
    {
        std::vector<EGLAttrib> displayAttributes;
        displayAttributes.push_back(EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE);
        displayAttributes.push_back(EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE);
        displayAttributes.push_back(EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE);
        displayAttributes.push_back(EGL_DONT_CARE);
        displayAttributes.push_back(EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE);
        displayAttributes.push_back(EGL_DONT_CARE);
        displayAttributes.push_back(EGL_NONE);
        display = eglGetPlatformDisplay(EGL_PLATFORM_ANGLE_ANGLE,
                                        reinterpret_cast<void *>(0),
                                        &displayAttributes[0]);
        if (eglGetError() != EGL_SUCCESS)
        {
            std::cerr << "Error on eglGetPlatformDisplay.\n";
            return false;
        }
        EGLint mEGLMajorVersion = 0;
        EGLint mEGLMinorVersion = 0;
        if (eglInitialize(display, &mEGLMajorVersion, &mEGLMinorVersion) == EGL_FALSE)
        {
            return false;
        }
        const char *displayExtensions = eglQueryString(display, EGL_EXTENSIONS);
        std::cout << "egl init: " << mEGLMajorVersion << "." << mEGLMinorVersion << " exts=" << displayExtensions << "\n";
    }
    
    //surface
    EGLConfig mConfig;
    {
        EGLint numConfigs = 0;
        eglGetConfigs(display, nullptr, 0, &numConfigs);
        std::vector<EGLConfig> allConfigs(numConfigs);
        eglGetConfigs(display, allConfigs.data(), static_cast<EGLint>(allConfigs.size()), &numConfigs);
        mConfig = allConfigs[0];
        
        {
            PrintConfigAttributes(display, mConfig);
        }
        
        std::vector<EGLint> surfaceAttributes;
        surfaceAttributes.push_back(EGL_NONE);
        
        std::cout << "try config=" << mConfig << " win="<< [mView layer] << "\n";
        mSurface = eglCreateWindowSurface(display, mConfig, [mView layer], &surfaceAttributes[0]);
        if (eglGetError() != EGL_SUCCESS || (mSurface == EGL_NO_SURFACE))
        {
            return false;
        }
    }
    
    // context
    EGLContext mContext;
    {
        eglBindAPI(EGL_OPENGL_ES_API);
        if (eglGetError() != EGL_SUCCESS)
        {
            std::cerr << "Error on eglBindAPI.\n";
            return false;
        }
        
        std::vector<EGLint> contextAttributes{
            EGL_CONTEXT_MAJOR_VERSION, 3,
            EGL_CONTEXT_MINOR_VERSION, 1};
        contextAttributes.push_back(EGL_NONE);
        
        mContext = eglCreateContext(display, mConfig, EGL_NO_CONTEXT, &contextAttributes[0]);
        EGLint err_code = eglGetError();
        if (err_code != EGL_SUCCESS) {
            std::cerr << "Error on eglCreateContext.\n";
            std::cout << eglErrorString(err_code) << "\n";
            return false;
        }
    }
    
    if (eglMakeCurrent(display, mSurface, mSurface, mContext) == EGL_FALSE || eglGetError() != EGL_SUCCESS)
    {
        std::cerr << "Error during eglMakeCurrent.\n";
        return false;
    }
    auto sss = glGetString(GL_VERSION);
    std::cout << sss << "\n";
    return true;
}

Geoff Lang

unread,
Feb 1, 2021, 11:12:37 AM2/1/21
to stir...@gmail.com, angleproject
Mac cannot support OpenGL ES 3.1 because their desktop GL driver only supports up 4.1 which does not have compute shaders.  We may support ES 3.1 in the future with our Metal backend though.

--
You received this message because you are subscribed to the Google Groups "angleproject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angleproject...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angleproject/58540e9c-9ed1-4a21-b59c-d4a6a3fc1dc9n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages