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