8
votes

is it possible to create a fixed size window using glut, so any changes with the window's dimensions will be disregarded.

it's kinda too late for me switching back to SDL or anything similar.

2
"it's kinda too late for me switching back to SDL or anything similar." I can't imagine how that would be a significant problem. GLUT is for window setup and management; switching managers should only require fairly localized changes. Unless you're dependent on GLUT-specific features, like sRGB framebuffers and the like.Nicol Bolas

2 Answers

13
votes

Apparently, it's not possible in a legit way, but you can use glutReshapeWindow inside your glutReshapeFunc-callback, to snap it back right after release of mouse. It's quite effective, and to my knowledge the best solution. Only tested with freeglut:

glutReshapeFunc(resize);

void resize(int width, int height) {
    // we ignore the params and do:
    glutReshapeWindow( 800, 600);
}
7
votes

Ultimately, no. The best you can do is call glutReshapeWindow to force it to a particular size whenever you detect that it has been resized. But that's about it. And if you do that, you need to do some infinite loop prevention by ensuring that you only call glutReshapeWindow if the new size isn't the same as the desired. This won't prevent the user from trying to resize it, but it'll prevent them from succeeding. Possibly.

Remember: GLUT is designed for demo applications and simple test-beds. For such application, the ability to resize the window is pretty standard.