void QEGLPlatformContext::adopt(const QVariant &nativeHandle, QPlatformOpenGLContext *share)
{
    if (!nativeHandle.canConvert<QEGLNativeContext>()) {
        qWarning("QEGLPlatformContext: Requires a QEGLNativeContext");
        return;
    }
    QEGLNativeContext handle = nativeHandle.value<QEGLNativeContext>();
    EGLContext context = handle.context();
    if (!context) {
        qWarning("QEGLPlatformContext: No EGLContext given");
        return;
    }

    // A context belonging to a given EGLDisplay cannot be used with another one.
    if (handle.display() != m_eglDisplay) {
        qWarning("QEGLPlatformContext: Cannot adopt context from different display");
        return;
    }

    // Figure out the EGLConfig.
    EGLint value = 0;
    eglQueryContext(m_eglDisplay, context, EGL_CONFIG_ID, &value);
    EGLint n = 0;
    EGLConfig cfg;
    const EGLint attribs[] = { EGL_CONFIG_ID, value, EGL_NONE };
    if (eglChooseConfig(m_eglDisplay, attribs, &cfg, 1, &n) && n == 1) {
        m_eglConfig = cfg;
        m_format = q_glFormatFromConfig(m_eglDisplay, m_eglConfig);
    } else {
        qWarning("QEGLPlatformContext: Failed to get framebuffer configuration for context");
    }

    // Fetch client API type.
    value = 0;
    eglQueryContext(m_eglDisplay, context, EGL_CONTEXT_CLIENT_TYPE, &value);
    if (value == EGL_OPENGL_API || value == EGL_OPENGL_ES_API) {
        m_api = value;
        eglBindAPI(m_api);
    } else {
        qWarning("QEGLPlatformContext: Failed to get client API type");
        m_api = EGL_OPENGL_ES_API;
    }

    m_eglContext = context;
    m_shareContext = share ? static_cast<QEGLPlatformContext *>(share)->m_eglContext : 0;
    updateFormatFromGL();
}
void QEGLPlatformContext::initialize()
{
    updateFormatFromGL();
}
示例#3
0
void QEGLPlatformContext::initialize()
{
    if (m_eglContext != EGL_NO_CONTEXT)
        updateFormatFromGL();
}