2
我正在嘗試創建一個正方形,並在其上創建一個箭頭。它就像是一個類似於2D的儀表。但我不知道如何在廣場上創建箭頭。OpenGL正方形和箭頭
int count = 1;
for (float y = 1; y < 11; y++) {
y1 = y1 - 0.51;
y2 = y2 - 0.51;
float x2 = -2.0;
for (float x1 = -2.5; x1 < 2.5; x1 = x1 + 0.51) {
glColor3f(windy[count], 1.0, 0.0);
glVertex2f(x1, y1);
glVertex2f(x1, y2);
glVertex2f(x2, y2);
glVertex2f(x2, y1);
count = count + 1;
x2 = x2 + 0.51;
}
}
glutSwapBuffers();
glEnd(); //End the glBegin Function
這就是我想要的。
glBegin(GL_LINE_LOOP);//start drawing a line loop
glVertex3f(-1.0f, 0.0f, 0.0f);//left of window
glVertex3f(0.0f, -1.0f, 0.0f);//bottom of window
glVertex3f(1.0f, 0.0f, 0.0f);//right of window
glVertex3f(0.0f, 1.0f, 0.0f);//top of window
glEnd();//end drawing of line loop
你不應該交換緩衝中介於'glBegin'和'glEnd'之間 – BeyelerStudios
@Java_NewBie:我的回答對你有幫助嗎? – Mykola