开发者

OpenGL ES (on iOS):

开发者 https://www.devze.com 2023-03-01 02:27 出处:网络
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);

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 ve开发者_运维技巧rtices 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消