Reshape window...


I don’t speak very well english… sorry!

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…

Somebody have an idee?

Thank you for your help!


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
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;
glViewport(0, 0, w, h);
gluPerspective(45, ratio, 1, 1000);

Hope this helps

Hi, thank you for your help…

It’s not exactly the reply to my question…

void reshape (int l, int h)

if (h < 200)
h = 200;

if (l < 200)
l = 200;

You see… I’d like put a minimal value for the window…

But this code doesn’t walk!

Have you an idee?

Best regards

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