is it possible to create a fixed size glut window?

南楼画角 提交于 2019-11-30 03:51:56

问题


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.


回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/10691603/is-it-possible-to-create-a-fixed-size-glut-window

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!