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. QOpenGl - VAO - crash crash crash!

QOpenGl - VAO - crash crash crash!

Scheduled Pinned Locked Moved Unsolved General and Desktop
qopenglwidgetqopenglbufferqopenglvertexar
1 Posts 1 Posters 530 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.
  • D Offline
    D Offline
    Dariusz
    wrote on 2 Jun 2019, 19:45 last edited by
    #1

    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!!!!!!

    1 Reply Last reply
    0

    1/1

    2 Jun 2019, 19:45

    • 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