Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to create a fixed size glut window?

Tags:

opengl

glut

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.

like image 828
igal k Avatar asked May 21 '12 19:05

igal k


2 Answers

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);
}
like image 142
mouse Avatar answered Oct 21 '22 15:10

mouse


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.

like image 32
Nicol Bolas Avatar answered Oct 21 '22 14:10

Nicol Bolas