View Full Version : How to maintain object size when resizing a window???
06-27-2002, 03:52 PM
I am trying to figure out how to maintain an objects size when resizing a window?
ex. A rectangle is 40 pixels high and 40 pixels wide when my window is 600x600. I want it to be 40 pixels high and 40 pixels wide when I shrink the window to 300x300.
Thanks for any replies.
06-27-2002, 10:00 PM
h0 = original height of the window
h1 = new height of the window
fov0 = original field of view
fov1 = new field of view
fov1 = atan( tan( fov0 / 2.0 ) * h1 / h0 ) * 2.0;
gluPerspective( fov1, w1/h1, near, far );
[This message has been edited by Jambolo (edited 06-28-2002).]
06-28-2002, 04:42 AM
Thanks for the reply Jambolo.
The reason that I was asking is because I want to create a user interface that alwasy stays the same size, even when my window is being resized.
Am I going about this all wrong? Is there a better way.
06-28-2002, 08:01 AM
If you're doing something 2d like a gui there is a much easier way. call gluOrtho2D(width/-2, width/2, height/-2, height/2)where width and height are the window dimensions in pixels. Then each vertex should approximately map to each pixel. It should exactly map to each pixel if the width and height are equal to the renderable space of the window and both are even numbers.
so every integral coordinate maps to a pixel.(0,0) is the lower left corner and (width,height) the upper right one.
07-01-2002, 03:52 PM
The glortho information sounds like what I was really looking for. I will give it a shot.
I really appreciate all the help!
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.