如何使用任何颜色的C ++在OpenGL中将形状填充为矩形,但不改变边框颜色(边框是形成矩形的线条)?
因为当我使用glBegin(GL_POLYGON)
函数填充矩形时,边框也被填充但我不想改变边框的颜色。
void display( )
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2i(50,90);
glVertex2i(100,90);
glVertex2i(100,150);
glVertex2i(50,150);
glEnd();
glFlush();
}
答案 0 :(得分:1)
void display( )
{
glClear(GL_COLOR_BUFFER_BIT);
// Draw the Polygon First
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2i(50,90);
glVertex2i(100,90);
glVertex2i(100,150);
glVertex2i(50,150);
glEnd();
// Draw the border next
glColor3f(0.0,1.0,0.0);
glBegin(GL_LINES);
glVertex2i(50,90);
glVertex2i(100,90);
glVertex2i(100,150);
glVertex2i(50,150);
glEnd();
glFlush();
}