Reputation: 71
How I can fill shape as rectangle in OpenGL using C++ with any color but without change the color it s border (border is the lines from which the rectangle is formed)?
Since when I used glBegin(GL_POLYGON)
function to fill the rectangle, the border is also filled but I do not want to change the color of border.
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();
}
Upvotes: 0
Views: 6673
Reputation: 3877
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();
}
Upvotes: 2