I seem to have a problem with loading a binary model file into the OpenGL vertex buffer extension. The file loads fine into a dynamic array, and using a "for" loop along with simple glVertex3f calls the model displays perfectly. But when I try to transfer it over to the buffer, the model will display with random geometry(such as a scrambled sphere, random triangles or just a splinter). Also, if I go above rougly 10k triangles, the render goes haywire. See for yourself in these pictures.
http://www.angelfire.com/space2/artib/VBO.html
I can't figure out what's wrong. Any help would be highly appreciated. I'm using interleaved arrays with the first 9 floats being 3 normals, the next 9 being 3 vertices. Here is my loading code:
#define BUFFER_OFFSET(i) ((char *)NULL + (i))
//Variables:
GLfloat *GlobalArray; //Pointer for the dynamic array
int GlobalArraySize=0; //How many elements in the dynamic array
GLuint buffer = 0; For the VBO buffer
This is in the init code:
OpenBinaryFile("c:/mace.jjj");//This inits and loads the DynamicArray
glGenBuffersARB(1, &buffer);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, GlobalArraySize*sizeof(float), GlobalArray, GL_STATIC_DRAW_ARB);
This is for the drawing:
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
static int nOffsetForNormals = 0; //No offset
static int nOffsetForVertices = sizeof(float) * 9; //Offset by 9 floats
glBindBufferARB( GL_ARRAY_BUFFER_ARB, buffer);
glNormalPointer( GL_FLOAT, 0, BUFFER_OFFSET(nOffsetForNormals));
glVertexPointer( 3, GL_FLOAT, 0, BUFFER_OFFSET(nOffsetForVertices));
glDrawArrays(GL_TRIANGLES, 0, GlobalArraySize);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
I've tried everything. Any help would be appreciated!