From 10:00 CET Friday 22nd November we will adjust how the server works to deal with some recently reported problems. Therefore there may be a load problem, if you experience more problems than usual trying to access the forum then please PM AndyS or any of the moderators so they can inform me.


QOpenGl - VAO - crash crash crash!



  • I'm out of ideas... wrrr!!!

    Ok so

    /// make by init VAO

    initializeGL(){
        makeCurrent();
        initializeOpenGLFunctions();
        mFunctions = new QOpenGLFunctions_4_5_Core();
        mFunctions->initializeOpenGLFunctions();
    
        getShader()->bind();
        mVao = new QOpenGLVertexArrayObject();
        mVao->create();
        mVao->bind();
    
        mVertexBuffer = new QOpenGLBuffer(QOpenGLBuffer::VertexBuffer);
        mVertexBuffer->create();
        mVertexBuffer->setUsagePattern(QOpenGLBuffer::StaticDraw);
        mVertexBuffer->bind();
    
       getShader()->enableAttributeArray("position");
       getShader()->setAttributeBuffer("position", GL_FLOAT, 0, 3, sizeof(QVector3D));
    
        mNormalsBuffer = new QOpenGLBuffer(QOpenGLBuffer::VertexBuffer);
        mNormalsBuffer->create();
        mNormalsBuffer->setUsagePattern(QOpenGLBuffer::StaticDraw);
        mNormalsBuffer->bind();
    
        mIndicesBuffer = new QOpenGLBuffer(QOpenGLBuffer::IndexBuffer);
        mIndicesBuffer->create();
        mIndicesBuffer->setUsagePattern(QOpenGLBuffer::StaticDraw);
        mIndicesBuffer->bind();
    
        mVertexBuffer->release();
        mNormalsBuffer->release();
        mIndicesBuffer->release();
        mVao->release();
    }
    

    add data to vao at latter data...

    void addData(vector<data>data){
    makeCurrent();
    ....
    ... process data in to 3 vectors 
    
        mVao->bind();
    
        mVertexBuffer->bind();
        mVertexBuffer->allocate(mVertex.get(), verteSize * sizeof(VRay::Vector));
        
        getShader()->enableAttributeArray("position");
        getShader()->setAttributeBuffer("position", GL_FLOAT, 0, 3, sizeof(VRay::Vector));
    
        mNormalsBuffer->bind();
        mNormalsBuffer->allocate(mNormals.get(), normalsSize * sizeof(VRay::Vector));
    
        mIndicesBuffer->bind();
        mIndicesBuffer->allocate(mIndices.get(), indicesSize * sizeof(int));
        
        mVertexBuffer->release();
        mNormalsBuffer->release();
        mIndicesBuffer->release();
        mVao->release();
        doneCurrent();
    }
    

    And paint :

    
    paintGl(){
    getShader()->bind();
    vao->bind();
    
    glDrawElementsBaseVertex()
    vao->release();
    getShader()->release();
    }
    

    And I just get a crash every time... If I bind QOpenGLBuffer in paint GL after vao->bind(), everything runs, but then I'm not using VAO but buffers... what on earth am I doing wrong here?! QT!!!!!!