PDA

View Full Version : Reshape window...



Boubou
12-03-2000, 11:57 PM
Hi,

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!

Jérôme

MrShoe
12-04-2000, 12:35 AM
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();
}

Hope this helps http://www.opengl.org/discussion_boards/ubb/smile.gif

Boubou
12-04-2000, 04:56 AM
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;
glutInitWindowSize(l,h);

}
if (l < 200)
{
l = 200;
glutInitWindowSize(l,h);
}


You see... I'd like put a minimal value for the window...

But this code doesn't walk!

Have you an idee?

Best regards
Jérôme

Moz
12-04-2000, 05:33 AM
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);