
如何对 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(); 展开
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(); 展开
展开全部
//初始化
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);
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);
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询