PDA

View Full Version : pop up menu problem in glut



onlyhuman23
08-01-2002, 06:54 PM
The problem is that I have to make a sort of a clock in the program but for doing that I will have to update the display every other second. The problem is that by displaying it so rapidly I wont be able to use the pop up menu as whenever the display is updated with glUpdateDisplay(), the pop up menu doesnt show. Please help me as when to create the menu in the program as I do that in main(). or is there another solution to this problem. Secondly when should the fullscreen mode be called. I am adding the sequence of my function calls bellow:

//myDisplay
void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT); //clear the screen
boardRect();
displayQ();
displayStacks();
myTable();
glFlush(); //send all output to display
}
//<<<<<<<<<<<<<<<<Start of Main>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void main(int argc, char** argv)
{
glutInit(&argc, argv); //initialize the toolkit
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); //set display mode
glutInitWindowSize(screenWidth, screenHeight); //set window size
// glutInitWindowPosition(100,100); //set window position on screen
var=glutCreateWindow("Dot plot of a function"); //open the screen window
glutFullScreen();
// glutMouseFunc(myMouse);
glutDisplayFunc(myDisplay); //register redraw function
myInit();
glutReshapeFunc(myReshape);
createGLUTMenus();
// glutTimerFunc(3000,myUpdate,0);
glutMainLoop(); //go into a perpetual loop

// rq_front=rq_rear=NULL;
// stkfirst=NULL,stkfirst2=NULL,stkfirst3=NULL,stkfir st4=NULL;
}
//<<<<<<<<<<<<<<<<<<End of the Main Function>>>>>>>>>>>>>>>>>>>
//<<<<<<<<<<<<<<<<<<myReshape Func>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void myReshape(GLsizei W, GLsizei H)
{
glViewport(0,0,W,H);
}

nexusone
08-02-2002, 07:56 AM
One thing you could do on the update is use glutTimerFunc( time in ms, func to call, 0) and just have the timmer run out in 2000 ms.

another would be to use glutIdleFunc(), this is a loose example...


my_idle_func()
{

if ( time_past - current_time > 2 seconds) //
{
glutRepostDisplay(); Update display every 2 seconds
time_past = current_time; // reset time
}

}

My_menu(int option)
{
if( option == 0) exit;
}


main()
{


menu = glutCreateMenu(My_menu);
glutAddMenuEntry("QUIT",0);


glutMainLoop(); // the last thing you call from main.... anything after it will not be called.
}


Originally posted by onlyhuman23:
The problem is that I have to make a sort of a clock in the program but for doing that I will have to update the display every other second. The problem is that by displaying it so rapidly I wont be able to use the pop up menu as whenever the display is updated with glUpdateDisplay(), the pop up menu doesnt show. Please help me as when to create the menu in the program as I do that in main(). or is there another solution to this problem. Secondly when should the fullscreen mode be called. I am adding the sequence of my function calls bellow:

//myDisplay
void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT); //clear the screen
boardRect();
displayQ();
displayStacks();
myTable();
glFlush(); //send all output to display
}
//<<<<<<<<<<<<<<<<Start of Main>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void main(int argc, char** argv)
{
glutInit(&argc, argv); //initialize the toolkit
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); //set display mode
glutInitWindowSize(screenWidth, screenHeight); //set window size
// glutInitWindowPosition(100,100); //set window position on screen
var=glutCreateWindow("Dot plot of a function"); //open the screen window
glutFullScreen();
// glutMouseFunc(myMouse);
glutDisplayFunc(myDisplay); //register redraw function
myInit();
glutReshapeFunc(myReshape);
createGLUTMenus();
// glutTimerFunc(3000,myUpdate,0);
glutMainLoop(); //go into a perpetual loop

// rq_front=rq_rear=NULL;
// stkfirst=NULL,stkfirst2=NULL,stkfirst3=NULL,stkfir st4=NULL;
}
//<<<<<<<<<<<<<<<<<<End of the Main Function>>>>>>>>>>>>>>>>>>>
//<<<<<<<<<<<<<<<<<<myReshape Func>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void myReshape(GLsizei W, GLsizei H)
{
glViewport(0,0,W,H);
}