So I am trying to implement vertex arrays, but neither glDrawArrays, glDrawElements, or glInterleavedArrays are working for me.
Here is my current code:
Geometry::vertex **vertices = pGeo->getVertexArray();
Geometry::vertex **normals = pGeo->getNormalArray();
Geometry::color **colors = pGeo->getColorArray();
//Geometry::texture **textures = pGeo->getTextureArray();
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
//glEnableClientState(GL_TEXTURE_ARRAY);
glVertexPointer( 3, GL_FLOAT, 0, vertices );
glNormalPointer( GL_FLOAT, 0, normals);
glColorPointer( 3, GL_FLOAT, 0, colors );
//glTexCoordPointer( 2, GL_FLOAT, 0, textures );
glDrawElements(GL_TRIANGLES, pGeo->getIndices().size(), GL_UNSIGNED_INT, pGeo->getIndexArray());
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
The screen just shows up blank. However, this code works:
vector<VertexPtr> vertices = pGeo->getVertices();
vector<int> indices = pGeo->getIndices();
glBegin(GL_TRIANGLES);
for(unsigned int i = 0; i < indices.size(); ++i)
{
VertexPtr v = vertices[indices];
Vector3Ptr pos = v->getPosition();
Vector3Ptr normal = v->getNormal();
glNormal3f(normal->x, normal->y, normal->z);
glColor3f(v->getR(), v->getG(), v->getB());
glVertex3f(pos->x, pos->y, pos->z);
}
glEnd();
Any idea whats going on? I don't think my vertice and indice arrays, et cetera, are corrupt, because I am directly copying them from my vectors<>.
Thanks!
<3 visage
[Edited by - visage on August 12, 2005 2:24:36 PM]