QAndroidEglFSPlatformContext::QAndroidEglFSPlatformContext(EGLDisplay display, EGLConfig config, EGLSurface surface, EGLenum eglApi)
    : QPlatformGLContext()
    , m_eglDisplay(display)
    , m_eglSurface(surface)
    , m_eglApi(eglApi)
{
    if (m_eglSurface == EGL_NO_SURFACE) {
        qWarning("Createing QEGLPlatformContext with no surface");
    }

    eglBindAPI(m_eglApi);

    EGLint attribList[3];
    attribList[0] = EGL_CONTEXT_CLIENT_VERSION;
    attribList[1] = 2;
    attribList[2] = EGL_NONE;


    m_eglContext = eglCreateContext(m_eglDisplay,config, EGL_NO_CONTEXT, attribList);
    qt_checkAndWarnAboutEGLError(__PRETTY_FUNCTION__, "eglCreateContext(m_eglDisplay,config, EGL_NO_CONTEXT, contextAttrs)");
    if (m_eglContext == EGL_NO_CONTEXT) {
        EGLint foo = eglGetError();
        qWarning("Could not create the egl context  .... error: %x\n", foo);
        eglTerminate(m_eglDisplay);
        qFatal("EGL error");
    }

    m_windowFormat = qt_qPlatformWindowFormatFromConfig(display,config);
//    m_windowFormat.setSharedContext(this);
}
Example #2
0
QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindowFormat &format)
    : QPlatformGLContext()
    , mEglDisplay(eglDisplay)
    , mSurface(EGL_NO_SURFACE)
    , mConfig(q_configFromQPlatformWindowFormat(mEglDisplay,format,true))
    , mFormat(qt_qPlatformWindowFormatFromConfig(mEglDisplay,mConfig))
{
    QPlatformGLContext *sharePlatformContext = 0;
    sharePlatformContext = format.sharedGLContext();
    mFormat.setSharedContext(sharePlatformContext);
    EGLContext shareEGLContext = EGL_NO_CONTEXT;
    if (sharePlatformContext)
        shareEGLContext = static_cast<const QWaylandGLContext*>(sharePlatformContext)->mContext;

    eglBindAPI(EGL_OPENGL_ES_API);

    QVector<EGLint> eglContextAttrs;
    eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
    eglContextAttrs.append(2);
    eglContextAttrs.append(EGL_NONE);

    mContext = eglCreateContext(mEglDisplay, mConfig,
                                shareEGLContext, eglContextAttrs.constData());
}
QPlatformWindowFormat QWaylandXCompositeEGLContext::platformWindowFormat() const
{
    return qt_qPlatformWindowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig);
}