PDA

View Full Version : creating a window and a subwindow with glut



dvm
05-04-2004, 04:33 AM
Hi, to everyone.
I'm writing a small application that's supposes to have a large window for putting large dots (ok bear with me) and a smaller subwindow on top that will display information about the state of the program.
The problem is that after I create my windows with this:

glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowPosition(10, 10);
glutInitWindowSize(g_WindowWidth, g_WindowHeight);
glutInit(&argc, argv);
g_iLevelWindow = glutCreateWindow("Coucou-Cache Level Editor");
glutDisplayFunc(Display);
glutReshapeFunc(Reshape);
glutKeyboardFunc(KInput);
glutMouseFunc(MInput);
glutMotionFunc(MMotionInput);
Initialize();
g_iInfoWindow = glutCreateSubWindow(g_iLevelWindow, 0, 0, g_WindowWidth, 100);
glutDisplayFunc(InfoDisplay);
glutReshapeFunc(InfoReshape);
glutKeyboardFunc(InfoKInput);
glutMouseFunc(InfoMInput);
InfoInitialize();
glutMainLoop();and handle the respective reshape callbacks with this:

// level window reshape
void Reshape(int w, int h)
{
glViewport(0, 0, w, h - 100);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-800.0f, 800.0f, -600.0f, 600.0f, -50.0f, 50.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
// info window reshape
void InfoReshape(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-(GLdouble)w / 2.0, (GLdouble)w / 2.0,
-(GLdouble)h / 2.0, (GLdouble)h / 2.0,
-10.0, 10.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}my smaller info window does not update properly when I resize the window. I mean that it doesn't expand to the full length of the window. The height remains firmly at 100 pixels, exactly where I want it. Can anyone help me as to what I'm doing wrong?