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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.