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

shademodel Subroutine

Purpose

Selects the shading style used to draw polygons and lines.

Libraries

Graphics Library

C (libgl.a)

FORTRAN (libfgl.a)

C Syntax

void shademodel(Int32 mode)

FORTRAN Syntax

SUBROUTINE SHADEM(mode)
INTEGER*4 mode

Description

The shademodel subroutine determines the shading style that the system uses to render lines and draw filled polygons. When the system uses Gouraud shading, the colors along a line segment or in the interior of a polygon are a linear interpolation of the colors at the vertices.

The shading model can be either FLAT or GOURAUD. When GOURAUD is specified, the colors along a line segment or the interior of a polygon are smooth shaded; that is, the color of a given pixel is a bi-linear interpolation of the colors at the vertices. When FLAT is specified, the entire primitive is drawn with one color.

When drawing flat-shaded polylines, each line segment is drawn with the current color. The current color is the color that was most recently specified before the vertex that defines the segment. That is, if a color is specified before the first vertex, and a second color is specified before the second (final) vertex, the line segment is drawn with the second color.

Parameter

mode Specifies one of two possible flags:
C FORTRAN Description
FLAT FLAT Instructs the system to draw polygons and lines in a constant color.
GOURAUD GOURAU Instructs the system to draw polygons and lines with Gouraud shading. (This is the default shading model.)

Example

The example C language program backface.c calls the shademodel subroutine, with the value of the mode parameter set to FLAT, to render the cube faster. This setting of the mode parameter shades each side of the cube in a constant color.

Implementation Specifics

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

The 3-D Color Graphics Processor does not support Gouraud-shaded lines. That is, the setting of the shademodel attribute is ignored when lines are drawn; all lines are drawn flat-shaded. An approximation can be achieved by drawing a 2-vertex polygon (with the bgnpolygon and endpolygon subroutines); however, 2-vertex polygons ignore the current setting of the linestyle, linewidth, and other line attributes.

When more than one color is specified for a primitive, and flat shading is enabled, the GXT1000 uses the OpenGL semantics to determine the color of the resulting primitive. For triangle meshes, the color used is the current color or the color most recently specified before the provoking vertex that caused the triangle to be drawn. For polygons, the polygon is drawn with the color that was current before the first vertex of the polygon was specified.

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

Returning the shading model used to draw polygons with the getsm subroutine.

Drawing with Move-Draw Style Subroutines, Drawing with Begin-End Style Subroutines, Setting Drawing Attributes, Understanding the Hardware Used by GL, Drawing Rectangles, Circles, Arcs, and Polygons.


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