Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: SOUQBALASLN CH. 4: The Stretch Factor
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SOUQBALASLN CH. 4: The Stretch Factor



Adam wrote:
On Dec 11, 2006, at 6:02 PM, David Duncan wrote:

On Dec 11, 2006, at 5:49 PM, Adam wrote:

No, I'm not talking about parabolas in Algebra II, I mean simply this: I build a window with a 1 by 1 box and dimensions of 640 by 480 and it makes my square into a rectangle! Why is this happening to me?

If your bounding box is 1x1, then that means that from 0=>1 takes you from pixel 0 to pixel 639 in the x direction, and pixel 0 to pixel 479 in the y direction. When you specify an nxn square be drawn, the n in the x direction counts for more pixels than the n in the y direction. But since pixels are square, this means that you have more pixels in one direction, leading to a rectangle rather than a square.


Moral of the story, build your context with the same aspect ratio as the underlying surface, or face the wrath of stretched images.
--
David Duncan
Apple DTS Quartz and Printing
email@hidden <mailto:email@hidden>



Ok, let me get this straight: in order to get the box to be a square, I'll have to scale it up about 1000x the number, then put:
glVertex3f(1000.0/screenwidth, 1000.0/screenheight, .... and then what? How would this work? Thank you for your help.

Well, something like that. If you define your viewing port as a 1x1 square, then "stretch" the square to 640x480 pixels, and *then* draw a 0.5x0.5 square, what will be the size of the square? Well, 320x240 of course. Which is not exactly a square. So if you want to have the right aspect ratio for a 0.5x0.5 square that actually looks like a square, then the idea is to have a viewing space in a 640x480 window that is proportional to 640x480. Of course, you can change the 0.5x0.5 square to have a different set of values dependent on your view, such as 0.5x(0.5*480/640) or 0.5x0.375. It might just make more sense to adjust your view though, to 1.0x0.75 (== 1.0x(1.0*480/640)).

Or, to start out, you could just have a window of 480x480 and be done
with it for now :).

-dan

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >SOUQBALASLN CH. 4: The Stretch Factor (From: Adam <email@hidden>)
 >Re: SOUQBALASLN CH. 4: The Stretch Factor (From: David Duncan <email@hidden>)
 >Re: SOUQBALASLN CH. 4: The Stretch Factor (From: Adam <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.