我正在製作一個簡單的二維繪圖程序,其中我有一個頂點數組(例如a1,a2,a3,.....),它將使用GL_LINE_STRIP進行繪製。問題是,假設有3個連續的頂點:p1,p2,p3,現在我想要如果(p2 ==某個特定的頂點值),則GL_LINE_STRIP應該在p1結束,並且新的GL_LINE_STRIP從p3開始,忽略p2。我想在p2中休息一下。我怎麼做?? PS:我試着在線條的循環中(線條寬度= 0),但發現由於opengl是一個狀態機,我們不能改變glBegin和GLEnd的寬度。這裏是一些失敗的示例代碼:。操縱GL_LINE_STRIP中的行
GLfloat thickness;
glBegin(GL_LINE_STRIP);
for(int i = 0; i < points.size(); i++)//points has all vertices stored...points is an array where each element is a structure containing x and y values
{
if(points[i].x==randomPoint.x || points[i-1].x==randomPoint.x){//checking if it is equal to p2(i am only checking x coordinate,which is sufficient for me to know that this point is to be excluded)
thickness = 0;
}else {
thickness = 4;
}
glLineWidth(thickness);
glVertex2i(points[i].x, points[i].y);
}
它的工作!在glBegin(GL_LINE_STRIP); \t對(INT I = 0; I