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. Get context /Id of QOpenGLBuffer, data wont render - debuging help.

Get context /Id of QOpenGLBuffer, data wont render - debuging help.

Scheduled Pinned Locked Moved Unsolved General and Desktop
openglqopengl
1 Posts 1 Posters 417 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 25 Dec 2018, 14:35 last edited by
    #1

    Hey

    I'm trying to debug a rather "complex" app. From the moment of creation of node to its render, I tried to follow context and debut it at every step. But so far my attempts appear to fail.

    The issue I have is that when I generate node, I create shader for it as well as vertex/indices buffer objects. The problem I however have is that when I want to render it and bind the buffers/programs I get a crash on render call.. Its doing my head for past 2 days. Is there a way to find out in what context was my buffer initially created or anything like that? I'm a bit lost.

    Here is part of my init function

    mVertexBuffer.create();
    mVertexBuffer.setUsagePattern(QOpenGLBuffer::StaticDraw);
    mVertexBuffer.bind();
    mVertexBuffer.allocate(vertices, 4 * sizeof(VertexData));
    
    mIndicesBuffer.create();
    mIndicesBuffer.setUsagePattern(QOpenGLBuffer::StaticDraw);
    mIndicesBuffer.bind();
    mIndicesBuffer.allocate(indices, 5 * sizeof(GLushort));
    
    mVertexBuffer.release();
    mIndicesBuffer.release();
    

    and during draw I call this:

    mVertexBuffer.bind();
    mIndicesBuffer.bind();
    mProgram.bind();
    mProgram.enableAttributeArray(mVertexLocationId);
    mProgram.setAttributeBuffer(mVertexLocationId, GL_FLOAT, offset, 3, sizeof(VertexData));
    offset += sizeof(QVector3D);
    mProgram.enableAttributeArray(mTexcoordLocationId);
    mProgram.setAttributeBuffer(mTexcoordLocationId, GL_FLOAT, offset, 2, sizeof(VertexData));
    mProgram.setUniformValue(mColorId, QVector4D(0.2,0.5,0.1,0.5));
    QMatrix4x4 trans;
    trans.translate(0.5, 0.5, 0.5);
    mProgram.setUniformValue(mMatrixLocationId, trans);
    glDrawElements(GL_TRIANGLE_STRIP, 5, GL_UNSIGNED_SHORT, 0);
    

    and glDrawElements pretty much either crash or renders nothing. If I, however, create the buffers again instead of binding old ones above then everything renders as needed. Its as if the bufferes were made in different context or something.

    btw do I need VAO ? - maybe I need to make VAO and then Buffer objects hmmm I'm lost.

    TIA

    1 Reply Last reply
    0

    1/1

    25 Dec 2018, 14:35

    • 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