Multiple Rendering Windows

I’m trying to render multiple windows with a different object in each window. When exploring this in GLUT, I found that you can open multiple windows and then assign a callback to each window when it is the current window. I currently can open two windows and draw two different squares but the one window doesn’t seem to update unless I click the window. I am changing the colors of each square slowly to check the updating, and the one correctly changes but the other will not change at all unless I click the opposite window then click back to the non-rendering window. Then the color changes but not gradually, just to the other color.

I can’t find any help on this topic but I believe that I am just making a small mistake.

int window1, window2;
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB |GLUT_DEPTH);
glutInitWindowSize(500, 500);
// create the first window
window1 = glutCreateWindow(“First Window - Perspective View”);
// register callbacks for first window, which is now current
glutReshapeFunc(window1_reshape);
glutDisplayFunc(window1_display); // window1_display
glutMouseFunc(window1_mouse);

//create the second window
window2 = glutCreateWindow(“Second Window - Top/Down View”);
//define a window position for second window
glutPositionWindow(520,20);
// register callbacks for second window, which is now current
glutReshapeFunc(window2_reshape);
glutDisplayFunc(window2_display);
glutMouseFunc(window2_mouse); //note we share the mouse function
glutIdleFunc(idle_func); //idle function is not associated with a
init();
glutMainLoop();

return 0;

}

Does anyone have any ideas how to render multiple contexts to multiple windows at once making sure that each window updates each frame (as often as possible)?

I don’t know what exactly you want to achieve. If you want to update each window separately, than glutTimerFunc() will be helpful. For each window you should have a timer that will redraw it on defined time interval. Be aware that defined time interval can slightly drift and it depends on system load and windows task scheduler (but you probably won’t control some real-time process with that drawing). But if you want to redraw all windows at the same moment, it will be the problem.

If separate thread controls drawing for each window, than after finishing drawing you can restart the whole process. But I don’t think it is a good idea (to redraw windows such often), because it will produce unnecessary high load and maybe system (GPU at first place) overheat.

I’m rendering multiple windows with one single display call. But with the IdleFunc containing my glutPostReDisplay(), only one window redisplays at a time. I need to have all the windows update as often as possible.

Any ideas?