[ Previous | Next | Contents | Glossary | Home | Search ]
GL3.2 for AIX: Graphics Library (GL) Technical Reference

viewport Subroutine

Purpose

Sets the area of the window used for all drawing.

Libraries

Graphics Library

C (libgl.a)

FORTRAN (libfgl.a)

C Syntax

void viewport
(Screencoord left, Screencoord right,
Screencoord bottom, Screencoord top)

FORTRAN Syntax

SUBROUTINE VIEWPO(left, right, bottom, top)
INTEGER*4 left, right, bottom, top
Note: For FORTRAN users, this subroutine accepts long integer parameters (INTEGER*4) when invoked from a FORTRAN program, although it accepts short integers when invoked from a C program. The C and FORTRAN syntax shown here reflect this difference.

Description

The viewport subroutine specifies, in pixels, the area of the window in which all drawing occurs. The viewport locations are specified relative to the lower left corner of the window. Specifying the viewport is the last step in mapping modeling coordinates to screen coordinates.

The portion of world space that the window, ortho, or perspective subroutines describe is mapped into the viewport. The left, right, bottom, top coordinates define a rectangular area on the screen.

The viewport is set to the size of the window when the window is first opened (thus, a getviewport would return the size of the window). However, if the window is resized, the viewport dimensions are not automatically updated (use the reshapeviewport subroutine). The viewport may be much larger or much smaller than the window size. All drawing occurs inside the current viewport, but is clipped to the window.

If the left parameter is greater than the right parameter, the displayed image will be left-right reversed. If the bottom parameter is greater than the top parameter, the displayed image will be up-down reversed.

The viewport is the mapping from normalized device coordinates (NDC) to device coordinates (DC). The same function is provided for the z-direction with the lsetdepth subroutine.

The viewport subroutine also resets the screenmask. The screenmask is set to be exactly the same size as the viewport.

Parameters

left Specifies the x location (in pixels) of left side of viewport.
right Specifies the x location (in pixels) of right side of viewport.
bottom Specifies the y location (in pixels) of bottom of viewport.
top Specifies the y location (in pixels) of top of viewport.

Example

The example C language program paint.c uses the viewport subroutine to define a viewport for displaying an image.

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 the viewport depth with the lsetdepth subroutine.

Popping the viewport off the viewport stack with the popviewport subroutine.

Pushing the viewport onto the viewport stack with the pushviewport subroutine.

Changing the viewport shape with the reshapeviewport subroutine.

Defining a rectangular 2-D clipping mask with the scrmask subroutine.

AIX Graphics Library Overview, Using Viewports and Screenmasks, and Working with Coordinate Systems.


[ Previous | Next | Contents | Glossary | Home | Search ]