Using FreeGLUT, how can I create an OpenGL window, specifying both title and screen location?

StackOverflow https://stackoverflow.com/questions/3366727

  •  04-10-2020
  •  | 
  •  

Question

The FreeGLUT API has several functions for window management:

int  glutCreateWindow(const char * title );
int  glutCreateSubWindow(int window, int x, int y, int width, int height);
void glutDestroyWindow(int window);
void glutSetWindow(int window);
int  glutGetWindow(void);
void glutSetWindowTitle(const char* title);
void glutSetIconTitle(const char* title);
void glutReshapeWindow(int width, int height);
void glutPositionWindow(int x, int y);

I'm completely new to this. How would I go about creating four windows, with unique titles and positions? It seems that once a second window has been created with glutCreateWindow(), there is no way to access the first one again.

So far, I can create a single window with glutCreateWindow("window 1");, then reshape and reposition it with glutReshapeWindow(width, height) and glutPositionWindow(x, y), but I'm at a loss as to how to manage several windows simultaneously.

I'm running MinGW/MSYS on Windows XP, if that helps.

Was it helpful?

Solution

Each time you create a window with glutCreateWindow it returns the window ID of the new window. You can store this in a variable and use this to access the window later via glutSetWindow.

Also note that you would normally set the display function for a window just after creating it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top