In my code, I have a wrapper class for an object supported by two buffer objects and a vertex array object. I generate them using this in the constructor (a bit simplistic):
glGenVertexArrays(1, &vao); glBindVertexArray(vao); glGenBuffers(1, &ibo); glGenBuffers(1, &vbo); printf("Ind buffers %d %d %d\n", vao, ibo, vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo);
printf gives this in the first few creations of the main thread.
Ind buffers 1 1 2 Ind buffers 3 4 5 Ind buffers 4 6 7 Ind buffers 5 8 9 Ind buffers 6 10 11 Ind buffers 7 12 13
There is one non-indexed intermediate that accepts VAO # 2 and buffer # 3. This looks good to me. Each array object receives two unique buffers attached to it.
I also use this code to load background resources (rather, create them). The streams for each of them have their own context created using glfwCreateContext and sharing resources with the main window. When these resources are first created, this output comes:
Ind buffers 1 14 15 Ind buffers 1 16 17 Ind buffers 1 18 19 Ind buffers 1 20 24 Ind buffers 1 21 23 Ind buffers 1 22 25 Ind buffers 1 26 27 Ind buffers 1 28 29 Ind buffers 2 30 31 Ind buffers 2 32 33 Ind buffers 2 34 35 Ind buffers 2 36 37 Ind buffers 2 39 40 Ind buffers 2 38 41 Ind buffers 2 42 43 Ind buffers 2 44 45
Very quickly after that, VAO # 1 is used to draw 9 times, using different numbers of vertices and inevitably something segfaults.
My question is: is this a mistake, or am I doing something clearly wrong? I am testing this on Linux Ubuntu with a Dell laptop with an Nvidia card.