Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


glOrtho help!


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 YodaTheCoder   Members   -  Reputation: 122

Like
Likes
Like

Posted 06 October 2001 - 04:49 PM

Please give me some syntax and examples using glOrtho or glOrtho2d... Im using it in a crappy little game like asteroids... Please help,..thanks!

Sponsor:

#2 Thek   Members   -  Reputation: 122

Like
Likes
Like

Posted 06 October 2001 - 06:06 PM

glOrtho() takes 6 parameters:
(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far)
left and right are x-axis coordinate bounds
bottom and top are the y-axis coordinate bounds
near and far are the z-axis coordinate bounds

gluOrtho2D() is just a special case of glOrtho() which automatically sets near and far (z-axis coordinate bounds) to be between -1.0 and 1.0.

These functions basically allow you to set up your own coordinate system for whatever drawing you want to do. Instead of drawing in actual screen coordinates, you would be drawing in your coordinate system, as you specified.

For example:
Say I wanted to draw a large square centered in the middle of a screen with the coordinate system specified as
glOrtho(-30.0, 30.0, -30.0, 30.0, 30.0, -30.0);
Here''s how I''d do it
glBegin(GL_QUADS);
glVertex3f(-25.0, -25.0, 0.0); //lower-left, z-axis at origin
glVertex3f(25.0, -25.0, 0.0); //lower-right
glVertex3f(25.0, 25.0, 0.0); //upper-right
glVertex3f(-25.0, 25.0, 0.0); //upper-left
glEnd();

This would leave a 5 unit space around the square, because the bounds of my coordinate system extended between -30 and 30 for every axis.

Hope this helps,
Thek




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS