Noob question about GLOrtho

Started by
1 comment, last by Sketchy 21 years, 9 months ago
Hey, I''m curious about GLOrtho, and what the point of it is. In my resizing function, I have: glOrtho(0.0f, width, 0.0f, height, 100.0, -100.0); //where width = 640, height = 480 I''m drawing a triangle, and if I resize the window, the triangle stays the same size. I''ve seen alot of code where they use ratios in glOrtho, and I''m not sure what thats all about. Will that resize my triangle to be the same size with respect to the window size? I can''t get ratios to do anything useful, other than mess up the dimensions of the triangle (it doesn''t look equilateral anymore) thx for any help
Advertisement
glOrtho is a 2D projection. think of your standard photoshop picture. That''s ortho, and can be described in pixels as opposed to units. therefor if you glTranslated(20,20,0); you will be moved 20 pixels to the right and 20 pixels up from the origin. (bottom left of the screen)

Jason FeserCode Geek / Visuals Guyelasticmediaproductionshttp://www.elasticvisuals.com
If you want your triangle to be scaled with your window, you must keep the values you pass to glOrtho the same.

So if you call
glOrtho(0.0f, width, 0.0f, height, 100.0, -100.0);
using the width and height of the actual window at the time you called the function (hopefuly you are using the client area), you will have the triangle stay the same size on the screen.

However if you want your triangle to scale with the window size, perhaps
glOrtho(0.0f, 640, 0.0f, 480, 100.0, -100.0);
Will be of some help.

Later on, you may want to keep everything the same size (particularly in ortho mode) despite what the size of your window is (this is what I am thinking of doing for 4e3). Then you must call glOrtho using the first method I mentioned, and then do some calculations to translate everything to the correct distance from the sides of of your window
(kind of like if you had an IE window and resized it, and everything would stay the same size (images, text) or change (some tables), but would change its position to fit properly on the screen)

I hope you got all that

Do not meddle in the affairs of moderators, for they are subtle and quick to anger.ANDREW RUSSELL STUDIOS
Cool Links :: [ GD | TG | MS | NeHe | PA | SA | M&S | TA ]
Got Clue? :: [ Start Here! | Google | MSDN | GameDev.net Refrence | OGL v D3D | File Formats | Go FAQ yourself ]

This topic is closed to new replies.

Advertisement