[ Next Article |
Previous Article |
Book Contents |
Library Home |
Legal |
Search ]

*GL3.2 for AIX: Graphics Library (GL) Technical Reference*

## perspective Subroutine

### Purpose

Defines a perspective projection transformation.

### Libraries

Graphics Library

C (**libgl.a**)

FORTRAN (**libfgl.a**)

### C Syntax

**void perspective**
**(Angle ***fovy***, **
**Float32** *aspect***, **
**Coord** *near***, Coord** *far***)**

### FORTRAN Syntax

**SUBROUTINE PERSPE(***fovy***, ***aspect***,** *near***,** *far***)**
**INTEGER*4 ***fovy*
**REAL ***aspect***, ***near***,** *far*

### Description

The **perspective** subroutine defines a perspective projection transformation by specifying a viewing pyramid in the eye coordinate system. The pyramid comprises:

- The field-of-view angle in the
*y* direction of the eye coordinate system
- The aspect ratio that determines the field-of-view in the
*x* direction
- The distance to the
*near* and *far* clipping planes in the *z* direction.

The field of view is the range of the area that is being viewed. The aspect ratio is the ratio of *x* (width) to *y* (height), and should match the aspect ratio of the associated
viewport. For example, *Aspect* = 2.0 means the viewer's angle of view is twice as wide in *x* as it is in *y*. If the viewport has the same aspect ratio as the frustum, it displays the image without distortion.

The **perspective** subroutine is very similar to the **window** subroutine. The only difference between these two is the manner in which the parameters specify the viewing frustum.

After the **perspective **subroutine completes, the eye coordinate system is set up so that x is to the right, y is up, and z is towards the viewer (out of the screen).

When the system is in
single matrix mode, the **perspective **subroutine loads a matrix onto the transformation stack, replacing the current top matrix. When the system is in
viewing matrix mode or projection matrix mode, the **perspective **subroutine replaces the current projection matrix and leaves the matrix stack unchanged.

### Parameters

*fovy* |
Specifies the field-of-view angle in the *y* direction. The field of view is the range of the area that is being viewed. It is measured in tenths of a degree. The value of *fovy* must be >= 2 (two-tenths of one degree) or an error results. |

*aspect* |
Specifies the aspect ratio which determines the field of view in the *x* direction. The aspect ratio is the ratio of *x* (width) to *y* (height). |

*near* |
Specifies the distance from the viewer to the closest clipping plane (always positive). |

*far* |
Specifies the distance from the viewer to the farthest clipping plane (always positive). |

### Example

The example C language program **zbuffer1.c** uses the **perspective** subroutine to load a projection transformation as the current transformation matrix.

### Implementation Specifics

This subroutine is part of GL in the AIXwindows Environment/6000 Version 1, Release 2 with AIXwindows/3D Feature.

### Files

**/usr/include/gl/gl.h** |
Contains C language constant and variable type definitions for GL. |

**/usr/include/gl/fgl.h** |
Contains FORTRAN constant and variable type definitions for GL. |

### Related Information

Defining a 3-D orthographic transformation with the **ortho** subroutine.

Defining a 2-D orthographic transformation with the **ortho2** subroutine.

Defining a perspective projection transformation in terms of *x* and *y* coordinates with the **window** subroutine.

AIX Graphics Library Overview and Working with Coordinate Systems.

[ Next Article |
Previous Article |
Book Contents |
Library Home |
Legal |
Search ]