Results 1 to 2 of 2

Thread: pop up menu problem in glut

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2001
    Location
    Islamabad,capital,Pakistan.
    Posts
    14

    pop up menu problem in glut

    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);
    }
    Only Human

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: pop up menu problem in glut

    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);
    }

Similar Threads

  1. GLUT menu creation problem (Blue Book v5, Linux)
    By musasabi in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-30-2012, 06:35 AM
  2. Frame freezes while the Glut menu is visible
    By Thor Henning Amdahl in forum OpenGL: General
    Replies: 0
    Last Post: 10-20-2006, 12:30 AM
  3. GLUT, How to add menu entries into the sub menu??
    By Asura in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-15-2006, 08:27 AM
  4. how to exit a program via a glut menu
    By Runz W Scissorz in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-21-2004, 01:14 PM
  5. problems updateing a glut menu
    By Andrew Davey in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-27-2004, 07:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean