I want to know the simplest method for using vbo's in OpenGL... I have tried running a few examples that work but are clouded with all other information thats making it really confusing me... at the moment this is what i have
GLuint vboId = 0;
const int trisize = (m_tris.size()/2)*3;//m_tris is an index array for verts and normals
GLfloat* vertices = new GLfloat[trisize];
GLfloat* normals = new GLfloat[trisize];
int j=0;
for (int i=0; i<m_tris.size(); i+=2) {
normals[j] = m_normals[m_tris[i+1]*3];
vertices[j++] = m_vertices[m_tris[i]*3];
normals[j] = m_normals[m_tris[i+1]*3+1];
vertices[j++] = m_vertices[m_tris[i]*3+1];
normals[j] = m_normals[m_tris[i+1]*3+2];
vertices[j++] = m_vertices[m_tris[i]*3+2];
} //im pretty sure this loop is right as its what i used before to display mesh correctly without vbo's using glVertex3f
glGenBuffersARB(1, &vboId);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vboId);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(vertices)+sizeof(normals), 0, GL_STATIC_DRAW_ARB);
glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(vertices), vertices);
glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, sizeof(vertices), sizeof(normals), normals);
glVertexPointer(sizeof(vertices), GL_FLOAT, 3, 0);
glNormalPointer(GL_FLOAT, 3, (void*)sizeof(vertices));
in a render method i have
glDrawArrays(GL_TRIANGLES, 0, this->getTriNum()); //0 is the vboId?
also i have a method that runs once...
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
when i try to run my code i get "EXC_BAD_ACCESS"
any advice on what im doing wrong... or a very simple implementation of a vbo would be very helpful