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);
    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?


I ran the program in debug mode, and found out that glVertexAttribPointer was NULL. After restarting my windows the program started running like it was before.

I am using glew along with win32 in VS2008, but one thing i do not understand is, why glVertexAttirbPOinter was NULL? I was initializing glew properly. and it was getting initialized everytime i started the program. Why i wasn't gettinga valid address for that method?

  • 3
    \$\begingroup\$ It could be that your graphics driver crashed during some earlier programming (or other shenanigans) and that Windows was unable to recover it fully. \$\endgroup\$ – Roy T. May 4 '14 at 12:04
  • \$\begingroup\$ hmm, could be. I did not get error, or anything, but i was playing a graphics hungry game before starting with OpenGL. \$\endgroup\$ – 2am May 4 '14 at 17:01
  • \$\begingroup\$ Laptop with switchable graphics? \$\endgroup\$ – Maximus Minimus Feb 28 '15 at 16:52
  • \$\begingroup\$ Yes Darth, it was a laptop with switchable graphics. \$\endgroup\$ – 2am Mar 1 '15 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.