I have a littre problem when the user want to change the dimension of my window… I’d like (when the dimension is too little) that the window cannot be too little. But I don’t know how can I do this…
Do you mean like a reshape function that keeps the drawn objects in the correct ratio when the window is resized?
If so, add to the main() function a line
glutReshapeFunc(reshape);
Then write a function called
void reshape(int w, int h){
float ratio;
if(h == 0){
h = 1; // Prevents divide by 0
}
ratio = 1.0 * w/h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, w, h);
gluPerspective(45, ratio, 1, 1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
Well, apparently, you’re using glut. The code you’ve got here doesn’t set the size of the window, it just reads the dimensions and store them in h and w and then all you do is changing the value of these variables with no effect to the window because you use initWindowSize which only work during initialisation !
You’d rather try this one :
void glutReshapeWindow(int width, int height);