Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Initial GLUT window at bottom of stack

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2002
    Location
    Cinn,.Oh.,USA
    Posts
    3

    Initial GLUT window at bottom of stack

    If a GLUT application has a "scanf" before initialization of GLUT, the GLUT window will show up at the bottom of the stack of the windows on W2000. It can be demonstrated by putting a "scanf" function call just before the glutInit line in the simple.c example program included with GLUT. Adding glutPopWindow at different places did not seem to help. If the "scanf" is removed, the GLUT window shows up at top of the window stack as desired. The "main" of simple.c with the "scanf" is shown below.
    Thanks

    main(int argc, char **argv)
    {

    //adding the scanf line causes the graphics window to show up at bottom of window stack
    float r;
    printf("input a number\n");
    scanf("%f",&r);
    printf("%f\n",r);

    glutInit(&argc, argv);
    glutCreateWindow("single triangle");
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    glutMainLoop();
    return 0; /* ANSI C requires main to return int. */
    }


    [This message has been edited by LBear (edited 11-18-2002).]

  2. #2
    Advanced Member Frequent Contributor marcus256's Avatar
    Join Date
    Aug 2001
    Location
    Sweden
    Posts
    853

    Re: Initial GLUT window at bottom of stack

    This is a problem with Windows, not GLUT (I believe). GLFW (another OpenGL toolkit) does some tricks to work around this problem.

    ...yet another "feature" introduced by Microsoft to make life easier for programmers

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2002
    Location
    Cinn,.Oh.,USA
    Posts
    3

    Re: Initial GLUT window at bottom of stack

    Thanks for the response!
    I thought of adding a routine to glut to get the handle of the GLUT parent window and doing a win32 BringWindowToTop, hoping that would cause a "display" callback or "visibility change" callback. I could not find where the parent window handle is stored in the GLUT C code as I'm not a strong C person, I work mostly in Fortran.

  4. #4
    Junior Member Newbie
    Join Date
    Nov 2002
    Location
    Cinn,.Oh.,USA
    Posts
    3

    Re: Initial GLUT window at bottom of stack

    Success!
    The handle for the GLUT parent window is stored in __glutWindowList[0] and it can be popped forward by calling SetForegroundWindow (instead of BringWindowToTop) with that handle, after GLUT initialization. The array __glutWindowList contains all the handles for the GLUT parent and all subwindows.

  5. #5
    Advanced Member Frequent Contributor marcus256's Avatar
    Join Date
    Aug 2001
    Location
    Sweden
    Posts
    853

    Re: Initial GLUT window at bottom of stack

    Originally posted by LBear:
    Success!
    Congratulations

    The handle for the GLUT parent window is stored in __glutWindowList[0] and it can be popped forward by calling SetForegroundWindow (instead of BringWindowToTop) with that handle, after GLUT initialization. The array __glutWindowList contains all the handles for the GLUT parent and all subwindows.
    Ahh, but be aware of this: SetForegroundWindow only works for foreground applications (typically a newly started application). If some seconds pass between application start and SetForegroundWindow, it is likely that your app is no longer the foreground app, and then SetForegroundWindow will do nothing (except for under Win 95 & NT 4).

    This may not be important to you, but if it is, you are free to have a look at the GLFW source (see init.c : glfwInit, and window.c : _glfwSetForegroundWindow + glfwOpenWindow).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •