Yea I use double buffering
Here’s my code :
////////////////////////////
void options()
{
cout << "one
";
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
cout << "two
";
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
cout << "three
";
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}
///////////////////////////////
void main_option()
{ /* some drawing, and make the value of icon_move to be -6 or -9 so that it goes to the keyboardfunc then keyboardfunc call options func */ }
///////////////////////////////
void display()
{
glEnable(GL_DEPTH_TEST);
glClearColor(0,0,0,1);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0,0,5,0,0,0,0,1,0);
main_options();
glutSwapBuffers();
}
////////////////////////////////
void key(unsigned char key, int x, int y)
{
switch(key) {
case 13:
switch(icon_move) {
case -6:
options();
break;
case -9:
exit(0);
break;
}
glutPostRedisplay();
}