why is glVertexAttribDivisor crashing?
        Posted  
        
            by 
                2am
            
        on Game Development
        
        See other posts from Game Development
        
            or by 2am
        
        
        
        Published on 2014-05-04T04:16:07Z
        Indexed on 
            2014/06/03
            9:37 UTC
        
        
        Read the original article
        Hit count: 372
        
I am trying to render some trees with instancing. This is rather weird, but before sleeping yesterday night, I checked the code, and it was in a running state, when I got up this morning, it is crashing when I am calling glVertexAttribDivisor I haven't changed any code since yesterday.
Here is how I am sending data to GPU for instancing.
    glGenBuffers(1, &iVBO);
    glBindBuffer(GL_ARRAY_BUFFER, iVBO);
    glBufferData(GL_ARRAY_BUFFER, (ml_instance->i_positions.size()*sizeof(glm::vec4)) , NULL, GL_STATIC_DRAW);
    glBufferSubData(GL_ARRAY_BUFFER, 0, (ml_instance->i_positions.size()*sizeof(glm::vec4)), &ml_instance->i_positions[0]);
And then in vertex specification--
    glBindBuffer(GL_ARRAY_BUFFER, iVBO);
    glVertexAttribPointer(i_positions, 4, GL_FLOAT, GL_FALSE, 0, 0);
    glEnableVertexAttribArray(i_positions);
    glVertexAttribDivisor(i_positions,1); // **THIS IS WHERE THE PROGRAM CRASHES**
    glDrawElementsInstanced(GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, 0,TREES_INSTANCE_COUNT);
I have checked ml_instance->i_positions, it has all the data that needs to render.
I have checked the value of i_positions in vertex shader, it is the same as whatever I have defined there.
I am little out of ideas here, everything looks pretty much fine. What am I missing?
© Game Development or respective owner