Windows – Multiple Windows OpenGL/Glut

glutopenglwindows

I would like to know how to open multiple OpenGL/Glut windows.
And I mean multiple windows at the same time
not subwindows and
not update the same window

Best Answer

While I believe the above answer is accurate, it is a little more complex then needed and it might be difficult when later having to deal with moving between the windows (say, for example, when drawing into them). This is what we've just done in class:

GLint WindowID1, WindowID2;                  // window ID numbers

glutInitWindowSize(250.0, 250.0);           // set a window size
glutInitWindowPosition(50,50);              // set a window position
WindowID1 = glutCreateWindow("Window One"); // Create window 1

glutInitWindowSize(500.0, 250.0);           // set a window size
glutInitWindowPosition(500,50);             // set a window position
WindowID2 = glutCreateWindow("Window Two"); // Create window 2

You will notice I'm using the same create window function but loading it into a GLint. That is because when we create a window this way, the function actually returns a unique GLint used by glut to identify windows.

We have to get and set windows to move between them and perform appropriate drawing functions. You can find the calls here.