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. GlGenVertexArrays has no effect in Qt5.0.2?
Forum Updated to NodeBB v4.3 + New Features

GlGenVertexArrays has no effect in Qt5.0.2?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 3.4k 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.
  • S Offline
    S Offline
    stereomatching
    wrote on last edited by
    #1

    platform : mac osx 10.8.3
    compiler : clang3.2

    Are these kind of codes do not work on Qt5.0.2?

    @
    GLuint vao;
    glGenVertexArrays(1, &vao);
    glBindVertexArray(vao);
    @

    example :

    This function has no effect in Qt5, VAO do not record the attributes at all
    It will overwrite the first object in the buffer
    @
    void ch5OverlapNoDepth::paintGL()
    {
    glClear(GL_COLOR_BUFFER_BIT);

    glBindVertexArray(vaoObject1_);
    glDrawElements(GL_TRIANGLES, indexData_.size(), GL_UNSIGNED_INT, 0);
    
    glBindVertexArray(vaoObject2_);
    glDrawElements(GL_TRIANGLES, indexData_.size(), GL_UNSIGNED_INT, 0);
    
    glBindVertexArray(0);
    

    }
    @

    If I want to let QGLWidget draw more than one object
    I have to bind the buffer and enable the attribute in the function
    @
    void ch5OverlapNoDepth::paintGL()
    {
    glClear(GL_COLOR_BUFFER_BIT);

    glBindBuffer(GL_ARRAY_BUFFER, positionBufferObject_[0]);
    
    size_t colorDataOffset = sizeof(GLfloat) * 4 * numberOfVertices;
    int vertexLocation = program_.attributeLocation("position");
    int colorLocation = program_.attributeLocation("color");    
    
    program_.enableAttributeArray(vertexLocation);
    program_.enableAttributeArray(colorLocation);
    
    glVertexAttribPointer(vertexLocation, 4, GL_FLOAT, GL_FALSE, 0, 0);
    glVertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid const*)colorDataOffset);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, positionBufferObject_[1]);
    glDrawElements(GL_TRIANGLES, indexData_.size(), GL_UNSIGNED_INT, 0);   
    
    size_t posDataOffset = sizeof(float) * 4 * (numberOfVertices / 2);
    colorDataOffset += sizeof(float) * 4 * (numberOfVertices / 2);
    
    //Use the same buffer object previously bound to GL_ARRAY_BUFFER.
    program_.enableAttributeArray(vertexLocation);
    program_.enableAttributeArray(colorLocation);
    glVertexAttribPointer(vertexLocation, 4, GL_FLOAT, GL_FALSE, 0, (void*)posDataOffset);
    glVertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, 0, (void*)colorDataOffset);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, positionBufferObject_[1]);
    glDrawElements(GL_TRIANGLES, indexData_.size(), GL_UNSIGNED_INT, 0);    
    

    }
    @

    This paintGL looks more expensive than the original paintGL which simply call the associate VAO
    How could I make use of VAO in Qt5.0.2?Thanks

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hesheit
      wrote on last edited by
      #2

      I now face with this problem like you. T_T

      1 Reply Last reply
      0
      • H Offline
        H Offline
        hesheit
        wrote on last edited by
        #3

        I can fix it.

        You need to make sure your opengl version is 3.0 or newer.
        glGenVertexArray is available in these versions and then use
        create(), bind() , etc instead.

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          ZapB
          wrote on last edited by
          #4

          Or use the QOpenGL_APPLE_vertex_array_object extension class if using OpenGL 2.1.

          Nokia Certified Qt Specialist
          Interested in hearing about Qt related work

          1 Reply Last reply
          0

          • Login

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