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 causes GL_INVALID_VALUE error
Forum Update on Monday, May 27th 2025

QOpenGLTexture::allocateStorage causes GL_INVALID_VALUE error

Scheduled Pinned Locked Moved Solved General and Desktop
opengltexture
2 Posts 1 Posters 892 Views
  • 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.
  • S Offline
    S Offline
    Stefan Monov76
    wrote on 20 Mar 2017, 16:40 last edited by Stefan Monov76
    #1

    Posting in this subforum as I think the error is not caused by my usage of Qt Quick.

    I've distilled this to trivial Qt code in which the only interesting thing is several lines in synchronize() handling a texture. I get a GL_INVALID_VALUE from the allocateStorage line. Anyone knows why? I suspect it's probably due to the parameters I pass to this function.

    My code:

    main.cpp:

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    #include <QQuickFramebufferObject>
    #include <QOpenGLFramebufferObject>
    #include <QOpenGLFunctions>
    #include <QOpenGLTexture>
    
    class MyItem : public QQuickFramebufferObject {
        Q_OBJECT
    
    public:
        Renderer* createRenderer() const;
    };
    
    class MyItemRenderer : public QQuickFramebufferObject::Renderer, protected QOpenGLFunctions {
    public:
        MyItemRenderer() {
            initializeOpenGLFunctions();
        }
    
        void render() {
        }
    
        QOpenGLFramebufferObject* createFramebufferObject(const QSize &size) {
            QOpenGLFramebufferObjectFormat format;
            format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
            return new QOpenGLFramebufferObject(size, format);
        }
    
    protected:
        void synchronize(QQuickFramebufferObject* qqfbo) {
            Q_UNUSED(qqfbo)
    
            QOpenGLTexture tex(QOpenGLTexture::Target2D);
            tex.setSize(100, 100);
            tex.allocateStorage(QOpenGLTexture::BGRA, QOpenGLTexture::Int8);
    
            qDebug() << "starting loop";
            GLenum err;
            while ((err = glGetError()) != GL_NO_ERROR) {
                qDebug("\tgl error: 0x%x", err, 0, 16);
            }
        }
    };
    
    QQuickFramebufferObject::Renderer* MyItem::createRenderer() const {
        return new MyItemRenderer();
    }
    
    int main(int argc, char **argv) {
        QGuiApplication app(argc, argv);
    
        qmlRegisterType<MyItem>("MyItem", 1, 0, "MyItem");
    
        QQmlApplicationEngine engine;
        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    
        return app.exec();
    }
    
    #include "main.moc"
    

    main.qml

    import QtQuick 2.0
    import MyItem 1.0
    import QtQuick.Window 2.2
    
    Window {
        visible: true
        width: 400
        height: 400
    
        MyItem {
            anchors.fill: parent
        }
    }
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      Stefan Monov76
      wrote on 20 Mar 2017, 17:32 last edited by
      #2

      I found a solution and posted it on StackOverflow

      1 Reply Last reply
      1

      1/2

      20 Mar 2017, 16:40

      • Login

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