Qt 5.5 QOpenGLTexture copy data

I work with Qt 5.5 OpenGL shell classes. In particular, an attempt to get QOpenGLTexture to work. Here I create a white 1x1 2D texture for masking. It works:

void Renderer::initTextures()
{    
    QImage white(1, 1, QImage::Format_RGBA8888);
    white.fill(Qt::white);
    m_whiteTexture.reset(new QOpenGLTexture(QOpenGLTexture::Target2D));
    m_whiteTexture->setSize(1, 1);
    m_whiteTexture->setData(white);
    //m_whiteTexture->allocateStorage(QOpenGLTexture::RGBA, QOpenGLTexture::UInt32);
    //m_whiteTexture->setData(QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, white.bits());

    // Print any errors
    QList<QOpenGLDebugMessage> messages = m_logger->loggedMessages();
    if (messages.size())
    {
        qDebug() << "Start of texture errors";
        foreach (const QOpenGLDebugMessage &message, messages)
            qDebug() << message;
        qDebug() << "End of texture errors";
    }
}

However, now I am trying to do two things:

  • Use the allocate + setData command as separate commands (commented out lines), e.g.

    m_whiteTexture->allocateStorage(QOpenGLTexture::RGBA, QOpenGLTexture::UInt32);
    m_whiteTexture->setData(QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, white.bits());
    

for more complex rendering later, when I just update part of the data and not redistribute it. Related to this (2), where I want to go to Target2DArray and push / pop textures in this array.

  1. Create a Target2DArray texture and fill the layers with QImages. In the end I will push / pop up the textures to some maximum size available on the hardware.

As for (1), I get these errors from the QOpenGLDebugMessage logger:

Start of texture errors
QOpenGLDebugMessage("APISource", 1280, "Error has been generated. GL error GL_INVALID_ENUM in TextureImage2DEXT: (ID: 2663136273) non-integer <format> 0 has been provided.", "HighSeverity", "ErrorType")
QOpenGLDebugMessage("APISource", 1280, "Error has been generated. GL error GL_INVALID_ENUM in TextureImage2DEXT: (ID: 1978056088) Generic error", "HighSeverity", "ErrorType")
QOpenGLDebugMessage("APISource", 1281, "Error has been generated. GL error GL_INVALID_VALUE in TextureImage2DEXT: (ID: 1978056088) Generic error", "HighSeverity", "ErrorType")
QOpenGLDebugMessage("APISource", 1281, "Error has been generated. GL error GL_INVALID_VALUE in TextureSubImage2DEXT: (ID: 1163869712) Generic error", "HighSeverity", "ErrorType")
End of texture errors

, (1) (2). (2) Target2DArray, 1, , vec3 sampler3D .. (2) , . , , GPU, , . PixelType PixelFormat.

!

+4
1

, . setFormat

m_whiteTexture->setFormat(QOpenGLTexture::RGBA8_UNorm);
0

Source: https://habr.com/ru/post/1611792/


All Articles