Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Noob question about GLOrtho

This topic is 6009 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post

Link to post
Share on other sites
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)

Share this post

Link to post
Share on other sites
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.

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 ]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!