I am trying to use VBOs in conjuction with glDrawElements. I was using it fine up till now with my own models. But now I wrote a very simple .3ds loader which fills up my VBOs and now glDrawElements throws one segmentation fault. Here is the stack trace:
#0 76EFE23E ntdll!LdrWx86FormatVirtualImage() (C:\Windows\system32
#1 00000000 ??() (??:??)
As you can see my OS is Windows. I guess that the problem lies at the indices of the arrays. But how can I figure it out? I tried moving into the VBO only say the first 50 triangles of the model and then drawing them with glDrawElements but I still get the same error.
I am trying to think of other ways to figure out the problem. Do you have any tips as to how to debug such a problem?
This is how I transfer the data into the VBOS:
glBufferSubData(GL_ARRAY_BUFFER, m->vboOffset, m->getVerticesN()*sizeof(smVertex),m->getVertices() ); glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, m->iboOffset, m->getTrianglesN()*sizeof(unsigned short)*3,m->getTriangles() );
And this is how I use glDrawElements:
glDrawElements(GL_TRIANGLES, getModel(0).getTrianglesN(), GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));
I know that code won’t help a lot in determining the problem, so that’s why I am asking for things to look at so I can find it myself.
Thanks in advance people!