Hi all,
I’m trying to get VBOs running. Right now I have an array with the model-data in it, which I pass to the following functions:
glEnableClientState(GL_VERTEX_ARRAY);
glGenBuffersARB(1, &buffer2);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer2);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(data), data, GL_STATIC_DRAW_ARB);
I’m drawing it with:
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer2);
glVertexPointer(3, GL_FLOAT, 0, 0);
glDrawArrays(GL_TRIANGLES, 0, 2880);
This works pretty good right now.
So I thought about implementing the normals with a normal array, which I read out:
for(int i=0; i<numFaces; i++)
{
glNormal3f(normals[i].v[0], normals[i].v[1], normals[i].v[2]);
}
As I was using glVertex3f these coordinates worked without problems, so I read the coordinates into a file, copied them by hand in an array called normalz and tried to do a normal-array with them:
glEnableClientState(GL_NORMAL_ARRAY);
glGenBuffersARB(1, &norm);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, norm);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(normalz), normalz, GL_STATIC_DRAW_ARB);
I tried to bind them with:
glBindBufferARB(GL_ARRAY_BUFFER_ARB, norm);
glNormalPointer(GL_FLOAT, 0, NULL);
But now the object looks kindof weird. Some normals work, some don’t.
Any hints what I’m doing wrong?
Thanks and greetings