NAME

cxGeoTextureAdd - adds a texture to the current geometry object

C SPECIFICATION

#include <cx/Geometry.h>

enum cxGeoBindingLevel { CX_GEO_PER_DEFAULT, CX_GEO_PER_OBJECT, CX_GEO_PER_PART, CX_GEO_PER_FACE, CX_GEO_PER_FACE_INDEXED, CX_GEO_PER_VERTEX, CX_GEO_PER_VERTEX_INDEXED };

enum cxGeoTextureWrap { CX_GEO_TEXTURE_REPEAT, CX_GEO_TEXTURE_CLAMP };

void cxGeoTextureAdd( int ns, int nt, unsigned int *image, cxGeoTextureWrap wraps, cxGeoTextureWrap wrapt, cxGeoBindingLevel per )

FORTRAN SPECIFICATION

integer CX_GEO_PER_DEFAULT
integer CX_GEO_PER_OBJECT
integer CX_GEO_PER_PART
integer CX_GEO_PER_FACE
integer CX_GEO_PER_FACE_INDEXED
integer CX_GEO_PER_VERTEX
integer CX_GEO_PER_VERTEX_INDEXED

parameter (CX_GEO_PER_DEFAULT = 0) parameter (CX_GEO_PER_OBJECT = 1) parameter (CX_GEO_PER_PART = 2) parameter (CX_GEO_PER_FACE = 3) parameter (CX_GEO_PER_FACE_INDEXED = 4) parameter (CX_GEO_PER_VERTEX = 5) parameter (CX_GEO_PER_VERTEX_INDEXED = 6)

integer CX_GEO_TEXTURE_WRAP integer CX_GEO_TEXTURE_CLAMP

parameter (CX_GEO_TEXTURE_WRAP = 0) parameter (CX_GEO_TEXTURE_CLAMP = 1)

subroutine cxGeoTextureAdd(ns,nt,image,wraps,wrapt,per) integer ns integer nt integer image(ns, nt) integer wraps integer wrapt integer per

PARAMETERS

ns
The number of image pixels in the S (horizontal) direction.
nt
The number of image pixels in the T (vertical) direction.
image
The image to be mapped onto the geometry, as an array of unsigned 32-bit integers. Each entry is interpreted as a four-byte hexadecimal value containing the red, green, blue and alpha components of the pixel (in that order). The first entry in the array corresponds to the pixel in the bottom left corner (S = T = 0) of the image. The next entry corresponds to the next pixel to the right (increasing S).
wraps
A flag indicating what is to happen to the texture for texture coordinates in the S direction which are outside the range [0,1].
wrapt
A flag indicating what is to happen to the texture for texture coordinates in the T direction which are outside the range [0,1].
per
A flag indicating how the image is to be mapped onto the geometry.

DESCRIPTION

This function adds an image as a texture to the current point set, line set, polygon set, triangle mesh set, sphere set, cylinder set, or grid. The current object is the primitive most recently defined, or it may be explicitly set with cxGeoFocus(3E).

If the width (ns) or height (nt) of the texture is not a power of 2, or if either of these variables are greater than the maximum supported by OpenGL, then the image will be automatically scaled up or down to the next power of 2 or the maximum texture size. For maximum speed, this scaling is done using point-sampling; the image should be pre-filtered to a power of 2 smaller than the maximum texture size if more accurate resampling is required.

The function handles S and T texture coordinates which are outside the [0,1] range according to the setting of the wraps and wrapt flags:

CX_GEO_TEXTURE_REPEAT
The texture is repeated cyclically outside of [0,1].
CX_GEO_TEXTURE_CLAMP
The texture is clamped (i.e. the last row of image pixels are repeated) outside of [0,1].

The texture will be applied to the current shape in various ways, depending on whether texture coordinates have been previously defined with cxGeoTextureCoordinate2Define(3E), and on the setting of the per flag. It should be noted that many of these settings result in DEFAULT binding of the texture.

CX_GEO_PER_DEFAULT
Each shape defines its own default texture coordinates, which typically cause the texture to be applied across the whole surface of the shape.
CX_GEO_PER_OBJECT
Same as CX_GEO_PER_DEFAULT.
CX_GEO_PER_PART
Same as CX_GEO_PER_DEFAULT.
CX_GEO_PER_FACE
Same as CX_GEO_PER_DEFAULT.
CX_GEO_PER_FACE_INDEXED
Same as CX_GEO_PER_DEFAULT.
CX_GEO_PER_VERTEX
The texture coordinates are applied sequentially to the vertices of the current shape.
CX_GEO_PER_VERTEX_INDEXED
The texture coordinates are indexed per vertex on the shape.

SEE ALSO

cxGeoTextureCoordinate2Define(3E)
Last modified: May 25 14:15 1999
[ Documentation Home ]
© The Numerical Algorithms Group Ltd, Oxford UK. 1999