Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QOpenGLTexture -- allocateStorage and setData
Forum Updated to NodeBB v4.3 + New Features

QOpenGLTexture -- allocateStorage and setData

Scheduled Pinned Locked Moved General and Desktop
qt5.5openglqopengltexture
1 Posts 1 Posters 5.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    klox
    wrote on 16 Oct 2015, 12:15 last edited by
    #1

    I'm working with Qt 5.5 OpenGL wrapper classes. Specifically trying to get QOpenGLTexture working. Here I am creating a 1x1 2D white texture for masking purposes. This 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 I am now trying to do two things:

    1. Use allocate + setData sequence as separate commands (the commented out lines), e.g.
    m_whiteTexture->allocateStorage(QOpenGLTexture::RGBA, QOpenGLTexture::UInt32);
    m_whiteTexture->setData(QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, white.bits());
    

    for the purpose of more complicated rendering later where I just update part of the data and not reallocate. Related to this is (2) where I want to move to Target2DArray and push/pop textures in this array.

    1. Create a Target2DArray texture and populate layers using QImages. Eventually I will be pushing/popping textures up to some max size available on the hardware. Regarding (1), I get these errors from 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
    

    My mask works with the original code, but I can't get it to work in either (1) and (2) scenarios. For (2) I change the target to Target2DArray, change the size to include depth of 1, adjust my shaders to use vec3 texture coordinates and sampler3D for sampling, etc. I can post a more complete (2) example if that helps. I also don't understand these error codes and obviously difficult to debug on the GPU if that is what is going wrong. I've tried all sorts of PixelType and PixelFormat combinations.

    The other thing is I noticed the setData methods have been declared obsolete, leaving only the QImage setter available. How can I use this for Target2DArray? How can I adjust just some of the data now?

    Thanks!

    Cross-posted with SO: https://stackoverflow.com/questions/33149607/qt-5-5-qopengltexture-copying-data-issue

    1 Reply Last reply
    0

    1/1

    16 Oct 2015, 12:15

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved