Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

glOrtho help!

4: Adsense

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   

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!

#2 Thek   Members   

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.