igal k
igal k

Reputation: 1934

is it possible to create a fixed size glut window?

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.

Upvotes: 11

Views: 12026

Answers (2)

mouse
mouse

Reputation: 364

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);
}

Upvotes: 19

Nicol Bolas
Nicol Bolas

Reputation: 473222

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.

Upvotes: 8

Related Questions