I'm writing a program that allows the user to draw different shapes through the menu options, the shapes after being drawn need to be on the same screen, but the problem is that after choosing another option in the menu to draw another shape, the previous shape disappears. How can I fix this? This is my program:
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
if (shape == 1)
{
draw_rectangle();
}
if (shape == 2)
{
draw_circle();
}
glFlush();
}
void menu(int choice)
{
switch (choice)
{
case 1:
shape = 1;
break;
case 2:
shape = 2;
break;
}
glutPostRedisplay();
}
The glClear(GL_COLOR_BUFFER_BIT) is only in display().