Ejemplo n.º 1
0
void VideoMaterial::bind()
{
    DPTR_D(VideoMaterial);
    d.updateTexturesIfNeeded();
    const int nb_planes = d.textures.size(); //number of texture id
    if (d.update_texure) {
        for (int i = 0; i < nb_planes; ++i) {
            bindPlane(i);
        }
        d.update_texure = false;
        return;
    }
    if (d.textures.isEmpty())
        return;
    for (int i = 0; i < nb_planes; ++i) {
        OpenGLHelper::glActiveTexture(GL_TEXTURE0 + i);
        glBindTexture(GL_TEXTURE_2D, d.textures[i]);
    }
}
Ejemplo n.º 2
0
bool VideoMaterial::bind()
{
    DPTR_D(VideoMaterial);
    if (!d.updateTexturesIfNeeded())
        return false;
    const int nb_planes = d.textures.size(); //number of texture id
    if (nb_planes <= 0)
        return false;
    if (d.update_texure) {
        for (int i = 0; i < nb_planes; ++i) {
            bindPlane(i);
        }
        d.update_texure = false;
        return true;
    }
    for (int i = 0; i < nb_planes; ++i) {
        OpenGLHelper::glActiveTexture(GL_TEXTURE0 + i);
        glBindTexture(GL_TEXTURE_2D, d.textures[i]);
    }
    return true;
}
Ejemplo n.º 3
0
void QSGVlcVideoFrameMaterial::bindPlanes()
{
    if( 0 == m_planeTexIds[0] && 0 == m_planeTexIds[1] && 0 == m_planeTexIds[2] )
        glGenTextures( sizeof( m_planeTexIds ) / sizeof( m_planeTexIds[0] ), m_planeTexIds );

    QSharedPointer<const QmlVlcI420Frame> tmpFrame;
    m_frame.swap( tmpFrame );

    if( tmpFrame ) {
        Q_ASSERT( 0 == ( tmpFrame->width & 1 ) && 0 == ( tmpFrame->height & 1 ) );//width and height should be even
        const quint16 tw = tmpFrame->width;
        const quint16 th = tmpFrame->height;

        bindPlane( GL_TEXTURE1, m_planeTexIds[1], tmpFrame->uPlane, tw / 2, th / 2 );
        bindPlane( GL_TEXTURE2, m_planeTexIds[2], tmpFrame->vPlane, tw / 2, th / 2 );
        bindPlane( GL_TEXTURE0, m_planeTexIds[0], tmpFrame->yPlane, tw, th );
    } else {
        bindPlane( GL_TEXTURE1, m_planeTexIds[1], 0, 0, 0 );
        bindPlane( GL_TEXTURE2, m_planeTexIds[2], 0, 0, 0 );
        bindPlane( GL_TEXTURE0, m_planeTexIds[0], 0, 0, 0 );
    }
}
Ejemplo n.º 4
0
void QSGVlcVideoFrameMaterial::bindPlanes()
{
    QOpenGLFunctions* f = QOpenGLContext::currentContext()->functions();
    if( 0 == m_planeTexIds[0] && 0 == m_planeTexIds[1] && 0 == m_planeTexIds[2] )
        F( glGenTextures( sizeof( m_planeTexIds ) / sizeof( m_planeTexIds[0] ), m_planeTexIds ) );

    std::shared_ptr<const QmlVlcI420Frame> tmpFrame;
    m_frame.swap( tmpFrame );

    if( tmpFrame ) {
        Q_ASSERT( 0 == ( tmpFrame->width & 1 ) && 0 == ( tmpFrame->height & 1 ) );//width and height should be even
        const quint16 tw = tmpFrame->width;
        const quint16 th = tmpFrame->height;

        bindPlane( GL_TEXTURE1, m_planeTexIds[1], tmpFrame->uPlane, tw / 2, th / 2 );
        bindPlane( GL_TEXTURE2, m_planeTexIds[2], tmpFrame->vPlane, tw / 2, th / 2 );
        bindPlane( GL_TEXTURE0, m_planeTexIds[0], tmpFrame->yPlane, tw, th );
    } else {
        bindPlane( GL_TEXTURE1, m_planeTexIds[1], 0, 0, 0 );
        bindPlane( GL_TEXTURE2, m_planeTexIds[2], 0, 0, 0 );
        bindPlane( GL_TEXTURE0, m_planeTexIds[0], 0, 0, 0 );
    }
}