perticularly 1 VBO 1个多边形
哇。 1每个多边形的VBO不会有效。杀死顶点缓冲区的全部原因。顶点缓冲区的想法是将尽可能多的顶点塞进它。您可以将多个三角形条放入一个顶点缓冲区,或者呈现存储在一个缓冲区中的单独基元。
我需要一种方法来修改上面的代码,以便相反,它可能看起来更像是这样的:
这应该工作:
glBegin(GL_TRIANGLES);
for (v= 0; v < tri.strip[s].num_vertices-2; v++)
if (v & 1){
glVertex2d(tri.strip[s].vertex[v].x, tri.strip[s].vertex[v].y);
glVertex2d(tri.strip[s].vertex[v+1].x, tri.strip[s].vertex[v+1].y);
glVertex2d(tri.strip[s].vertex[v+2].x, tri.strip[s].vertex[v+2].y);
}
else{
glVertex2d(tri.strip[s].vertex[v].x, tri.strip[s].vertex[v].y);
glVertex2d(tri.strip[s].vertex[v+2].x, tri.strip[s].vertex[v+2].y);
glVertex2d(tri.strip[s].vertex[v+1].x, tri.strip[s].vertex[v+1].y);
}
glEnd();
因为trianglestrip三角是这样的(数字代表顶点索引):
0----2
| /|
|/|
|/|
|/ |
1----3
注意:I a假设三角形标签中的顶点以与我的图片相同的顺序存储,并且您希望三角形顶点按照逆时针顺序发送。如果你想要它们是CW,那么使用不同的代码:
glBegin(GL_TRIANGLES);
for (v= 0; v < tri.strip[s].num_vertices-2; v++)
if (v & 1){
glVertex2d(tri.strip[s].vertex[v].x, tri.strip[s].vertex[v].y);
glVertex2d(tri.strip[s].vertex[v+2].x, tri.strip[s].vertex[v+2].y);
glVertex2d(tri.strip[s].vertex[v+1].x, tri.strip[s].vertex[v+1].y);
}
else{
glVertex2d(tri.strip[s].vertex[v].x, tri.strip[s].vertex[v].y);
glVertex2d(tri.strip[s].vertex[v+1].x, tri.strip[s].vertex[v+1].y);
glVertex2d(tri.strip[s].vertex[v+2].x, tri.strip[s].vertex[v+2].y);
}
glEnd();
By 1 vbo per polygon我的意思是一系列的三角形,对不起 – jmasterx 2010-08-14 21:25:13