Reputation: 7319
I have a series of standard OpenGL instructions in this form:
glBegin(GL_TRIANGLES);
// ...
glNormal3fv(a); glVertex3f(a[0]*r, a[1]*r, a[2]*r);
// ...
glEnd();
I wish to run them on iOS, thus must convert them to OpenGL ES. Since OpenGL ES doesn't support glBegin() or glEnd(), I'm wrapping up the glVertex3f calls into a GLfloat vertices array followed by a glDrawArrays() call instead.
GLfloat vertices[] = {1,0,0, 0,1,0, ...};
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, vertices);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableClientState(GL_VERTEX_ARRAY);
However I'm unsure how to include the specification of a normal vector (the original glNormal3fv() calls) in this ES version.
Would someone be kind enough to exemplify the solution?
Upvotes: 2
Views: 1119
Reputation: 29047
Have a look at glNormalPointer()
. It works in much the same way as glVertexPointer()
, but with fewer options since normals always have 3 floating point components.
Upvotes: 4