Пример #1
0
void RenderTextureImage::sceneChangeEvent(const QSceneChangePtr &e)
{
    QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);

    if (e->type() == NodeUpdated) {
        if (propertyChange->propertyName() == QByteArrayLiteral("layer")) {
            m_layer = propertyChange->value().toInt();
            m_dirty = true;
        } else if (propertyChange->propertyName() == QByteArrayLiteral("mipmapLevel")) {
            m_mipmapLevel = propertyChange->value().toInt();
            m_dirty = true;
        } else if (propertyChange->propertyName() == QByteArrayLiteral("cubeMapFace")) {
            m_face = static_cast<QAbstractTextureProvider::CubeMapFace>(propertyChange->value().toInt());
            m_dirty = true;
        } else if (propertyChange->propertyName() == QByteArrayLiteral("dataFunctor")) {
            m_functor = propertyChange->value().value<QTextureDataFunctorPtr>();
            m_dirty = true;
        }
    }
    if (m_dirty) {// Notify the RenderTexture that we were updated and request it to schedule an update job
        RenderTexture *txt = m_textureManager->data(m_textureProvider);
        if (txt != Q_NULLPTR)
            txt->addToPendingTextureJobs();
    }
}
Пример #2
0
void RenderTextureImage::updateFromPeer(QNode *peer)
{
    QAbstractTextureImage *textureImage = static_cast<QAbstractTextureImage *>(peer);
    m_layer = textureImage->layer();
    m_mipmapLevel = textureImage->mipmapLevel();
    m_face = textureImage->cubeMapFace();
    m_functor = textureImage->dataFunctor();
    // Notify the RenderTexture that we are one of its TextureImage
    if (!peer->parentNode()) {
        qWarning() << "Not QAbstractTextureProvider parent found";
    } else {
        m_textureProviderId = peer->parentNode()->id();
        m_textureProvider = m_textureManager->lookupHandle(m_textureProviderId);
        RenderTexture *txt = m_textureManager->data(m_textureProvider);
        // Notify the RenderTexture that it has a new RenderTextureImage and needs an update
        txt->addTextureImageData(m_textureImageManager->lookupHandle(peerUuid()));
        if (txt != Q_NULLPTR)
            txt->addToPendingTextureJobs();
    }
}