222 223














Open GL Super Bible:Manipulating 3D Space: Coordinate Transformations















To access the contents, click the chapter and section titles.


Open GL Super Bible


(Publisher: Macmillan Computer Publishing)

Author(s): Waite group Press

ISBN: 1571690735

Publication Date: 08/01/96

 




Previous
Table of Contents
Next




gluOrtho2D

Purpose
Defines a two-dimensional orthographic projection.
Include File
<glu.h>
Syntax
void gluOrtho2D(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top);
Description
This function defines a 2D orthographic
projection matrix. This projection matrix is equivalent to calling
glOrtho with near and far set to 0 and 1, respectively.


Parameters

left, right

GLdouble: Specifies the far-left and -right clipping planes.
bottom, top

GLdouble: Specifies the top and bottom clipping planes.
Returns
None.


Example
The following line of code sets up a 2D viewing volume that allows drawing in the xy plane from
100 to +100 along the x- and y-axis. Positive y will be up, and positive x will be to the right.

gluOrtho2D(-100.0, 100.0, -100.0, 100.0);


See Also
glOrtho, gluPerspective


gluPerspective

Purpose
Defines a viewing perspective Projection matrix.
Include File
<glu.h>
Syntax
void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);
Description
This function creates a matrix that describes a
viewing frustum in world coordinates. The aspect ratio should match the
aspect ratio of the viewport (specified with glViewport). The
perspective division is based on the field-of-view angle and the
distance to the near and far clipping planes.


Parameters

fovy

GLdouble: The field of view in degrees, in the y direction.
aspect

GLdouble: The aspect ratio. This is used to determine the field of view in the x direction. The aspect ratio is x/y.
zNear, zFar

GLdouble: The distance from the viewer to the near and far clipping plane. These values are always positive.
Returns
None.


Example
The following code is from the example program SOLAR. It creates a Perspective projection that makes planets on the far side of the Sun appear smaller than when on the near side.

// Change viewing volume and viewport.
// Called when window is resized
void ChangeSize(GLsizei w, GLsizei h)
{
GLfloat fAspect;

// Prevent a divide by zero
if(h == 0)
h = 1;

// Set Viewport to window dimensions
glViewport(0, 0, w, h);

// Calculate aspect ratio of the window
Aspect = (GLfloat)w/(GLfloat)h;

// Reset coordinate system
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

gluPerspective(45.0f, fAspect, 1.0, 425.0);

// Modelview matrix reset
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}


See Also
glFrustum, gluOrtho2D






Previous
Table of Contents
Next














 


Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.












Wyszukiwarka

Podobne podstrony:
222 223
222 223
222 223
223 227 6fcwctb2pglckpptczkjmjgfc6sdcxsk6lmqcji
WCE2012 pp218 223
223 228
222 Ustawa o łagodzeniu skutków kryzysu ekonomicznego dla pracowników i przedsiębiorców
Mazowieckie Studia Humanistyczne r1997 t3 n1 s211 223
223 232
prawo;i;finanse,kategoria,222
222 224

więcej podobnych podstron