如何对 OPENGL 顶点数组进行赋值? 即glArrayElement(i) 如何运算?

GLfloatVertices[128][3];Vertices[0][0]=1;Vertices[0][1]=1;Vertices[0][2]=1;Vertices[1... GLfloat Vertices[128][3];

Vertices[0][0]=1;
Vertices[0][1]=1;
Vertices[0][2]=1;

Vertices[1][0]=-1;
Vertices[1][1]=1;
Vertices[1][2]=1;

Vertices[2][0]=-1;
Vertices[2][1]=-1;
Vertices[2][2]=1;

Vertices[3][0]=1;
Vertices[3][1]=-1;
Vertices[3][2]=1;

glEnableClientState(GL_VERTEX_ARRAY);
// glEnableClientState(GL_COLOR_ARRAY);
glVertexPointer(3,GL_FLOAT,0,Vertices);
glBegin(GL_LINE_LOOP);
glArrayElement(0);
glArrayElement(1);
glArrayElement(2);
glArrayElement(3);

glArrayElement(4)= glArrayElement(2)+ glArrayElement(3);
glEnd();
展开
 我来答
手机用户59435
2011-09-05 · TA获得超过161个赞
知道答主
回答量:220
采纳率:0%
帮助的人:122万
展开全部
//初始化
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glNormalPointer(GL_FLOAT,0,normals); //float normals[][3]
glVertexPointer(3,GL_FLOAT,0,vertices); //float vertices[][3]
...
//显示
...
for(int j=0;j<3;j++)
{
int idx=face_indicies[i][j];
// glNormal3fv(&normals[idx][0]);
// glVertex3fv(&vertices[idx][0]);
glArrayElement(idx);//获取当前所有已启用数组的一个顶点数据
}
------
或者把glBegin到End以及2个for替换成
glDrawElements(GL_TRIANGLES,
(sizeof(face_indicies)/sizeof(**face_indicies),
GL_UNSIGNED_INT, // unsigned int face_indicies[][]
face_indicies);
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式