_C_ License Applicability. Except to the extent portions of this file are _C_ made subject to an alternative license as permitted in the SGI Free _C_ Software License B, Version 1.1 (the "License"), the contents of this _C_ file are subject only to the provisions of the License. You may not use _C_ this file except in compliance with the License. You may obtain a copy _C_ of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 _C_ Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: _C_ _C_ http://oss.sgi.com/projects/FreeB _C_ _C_ Note that, as provided in the License, the Software is distributed on an _C_ "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS _C_ DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND _C_ CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A _C_ PARTICULAR PURPOSE, AND NON-INFRINGEMENT. _C_ _C_ Original Code. The Original Code is: OpenGL Sample Implementation, _C_ Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, _C_ Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. _C_ Copyright in any portions created by third parties is as indicated _C_ elsewhere herein. All Rights Reserved. _C_ _C_ Additional Notice Provisions: The application programming interfaces _C_ established by SGI in conjunction with the Original Code are The _C_ OpenGL(R) Graphics System: A Specification (Version 1.2.1), released _C_ April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version _C_ 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X _C_ Window System(R) (Version 1.3), released October 19, 1998. This software _C_ was created using the OpenGL(R) version 1.2.1 Sample Implementation _C_ published by SGI, but has not been independently verified as being _C_ compliant with the OpenGL(R) version 1.2.1 Specification. _C_ _C_ The first character in this file must be an '_'! _C_ Anything on a line after _C_ is ignored _define(_filters,eqn)_C_ _C_ eqn is automatically replaced with neqn for nroff _header(TexGen,control the generation of texture coordinates) _names(TexGen,[ifd]) .EQ delim $$ .EN .SH PARAMETERS _phead(_param1) Specifies a texture coordinate. Must be one of _const(S), _const(T), _const(R), or _const(Q). _phead(_param2) Specifies the symbolic name of the texture-coordinate generation function. Must be _const(TEXTURE_GEN_MODE). _phead(_param3) Specifies a single-valued texture generation parameter, one of _const(OBJECT_LINEAR), _const(EYE_LINEAR), or _const(SPHERE_MAP). _names(TexGen,[ifd]v) .SH PARAMETERS _phead(_param1) Specifies a texture coordinate. Must be one of _const(S), _const(T), _const(R), or _const(Q). _phead(_param2) Specifies the symbolic name of the texture-coordinate generation function or function parameters. Must be _const(TEXTURE_GEN_MODE), _const(OBJECT_PLANE), or _const(EYE_PLANE). _phead(_param3) Specifies a pointer to an array of texture generation parameters. If _param2 is _const(TEXTURE_GEN_MODE), then the array must contain a single symbolic constant, one of _const(OBJECT_LINEAR), _const(EYE_LINEAR), or _const(SPHERE_MAP). Otherwise, _param3 holds the coefficients for the texture-coordinate generation function specified by _param2. .SH DESCRIPTION _cmnd selects a texture-coordinate generation function or supplies coefficients for one of the functions. _param1 names one of the (\f2s\fP, \f2t\fP, \f2r\fP, \f2q\fP) texture coordinates; it must be one of the symbols _const(S), _const(T), _const(R), or _const(Q). _param2 must be one of three symbolic constants: _const(TEXTURE_GEN_MODE), _const(OBJECT_PLANE), or _const(EYE_PLANE). If _param2 is _const(TEXTURE_GEN_MODE), then _param3 chooses a mode, one of _const(OBJECT_LINEAR), _const(EYE_LINEAR), or _const(SPHERE_MAP). If _param2 is either _const(OBJECT_PLANE) or _const(EYE_PLANE), _param3 contains coefficients for the corresponding texture generation function. .P If the texture generation function is _const(OBJECT_LINEAR), the function .P .ce $g ~=~ p sub 1^x sub o ~+~ p sub 2^y sub o ~+~ p sub 3^z sub o ~+~ p sub 4^w sub o$ .P .br is used, where $g$ is the value computed for the coordinate named in _param1, $p sub 1$, $p sub 2$, $p sub 3$, and $p sub 4$ are the four values supplied in _param3, and $x sub o$, $y sub o$, $z sub o$, and $w sub o$ are the object coordinates of the vertex. This function can be used, for example, to texture-map terrain using sea level as a reference plane (defined by $p sub 1$, $p sub 2$, $p sub 3$, and $p sub 4$). The altitude of a terrain vertex is computed by the _const(OBJECT_LINEAR) coordinate generation function as its distance from sea level; that altitude can then be used to index the texture image to map white snow onto peaks and green grass onto foothills. .P If the texture generation function is _const(EYE_LINEAR), the function .P .ce $g ~=~ p sub 1 sup prime ^x sub e ~+~ p sub 2 sup prime ^y sub e ~+~ p sub 3 sup prime ^z sub e ~+~ p sub 4 sup prime ^w sub e$ .P .br is used, where .P .ce $( p sub 1 sup prime ~~p sub 2 sup prime~~p sub 3 sup prime~~ { p sub 4 sup prime}) ~=~ ( p sub 1~~ p sub 2~~ p sub 3~~ p sub 4 ) ~M sup -1$ .P .br and $x sub e$, $y sub e$, $z sub e$, and $w sub e$ are the eye coordinates of the vertex, $p sub 1$, $p sub 2$, $p sub 3$, and $p sub 4$ are the values supplied in _param3, and $M$ is the modelview matrix when _cmnd is invoked. If $M$ is poorly conditioned or singular, texture coordinates generated by the resulting function may be inaccurate or undefined. .P Note that the values in _param3 define a reference plane in eye coordinates. The modelview matrix that is applied to them may not be the same one in effect when the polygon vertices are transformed. This function establishes a field of texture coordinates that can produce dynamic contour lines on moving objects. .P If _param2 is _const(SPHERE_MAP) and _param1 is either _const(S) or _const(T), $s$ and $t$ texture coordinates are generated as follows. Let \f2u\fP be the unit vector pointing from the origin to the polygon vertex (in eye coordinates). Let \f2n\fP sup prime be the current normal, after transformation to eye coordinates. Let .P .ce $f ~=~ ( f sub x~~f sub y~~f sub z ) sup T$ be the reflection vector such that .P .ce $f ~=~ u ~-~ 2 n sup prime n sup prime sup T u$ .br .P Finally, let $ m ~=~ 2 sqrt { f sub x sup {~2} ~+~ f sub y sup {~2} ~+~ (f sub z ~+~ 1 ) sup 2}$. Then the values assigned to the $s$ and $t$ texture coordinates are .P .ce 1 $s ~=~ f sub x over m ~+~ 1 over 2$ .sp .ce 1 $t ~=~ f sub y over m ~+~ 1 over 2$ .P To enable or disable a texture-coordinate generation function, call _cmnd(Enable) or _cmnd(Disable) with one of the symbolic texture-coordinate names (_const(TEXTURE_GEN_S), _const(TEXTURE_GEN_T), _const(TEXTURE_GEN_R), or _const(TEXTURE_GEN_Q)) as the argument. When enabled, the specified texture coordinate is computed according to the generating function associated with that coordinate. When disabled, subsequent vertices take the specified texture coordinate from the current set of texture coordinates. Initially, all texture generation functions are set to _const(EYE_LINEAR) and are disabled. Both $s$ plane equations are (1, 0, 0, 0), both $t$ plane equations are (0, 1, 0, 0), and all $r$ and $q$ plane equations are (0, 0, 0, 0). .P When the _arbstring(multitexture) extension is supported, _cmnd set the texture generation parameters for the currently active texture unit, selected with _cmnd(ActiveTextureARB). .SH ERRORS _const(INVALID_ENUM) is generated when _param1 or _param2 is not an accepted defined value, or when _param2 is _const(TEXTURE_GEN_MODE) and _param3 is not an accepted defined value. .P _const(INVALID_ENUM) is generated when _param2 is _const(TEXTURE_GEN_MODE), _param3 is _const(SPHERE_MAP), and _param1 is either _const(R) or _const(Q). .P _const(INVALID_OPERATION) is generated if _cmnd is executed between the execution of _cmnd(Begin) and the corresponding execution of _cmnd(End). .SH ASSOCIATED GETS _cmnd(GetTexGen) .br _cmnd(IsEnabled) with argument _const(TEXTURE_GEN_S) .br _cmnd(IsEnabled) with argument _const(TEXTURE_GEN_T) .br _cmnd(IsEnabled) with argument _const(TEXTURE_GEN_R) .br _cmnd(IsEnabled) with argument _const(TEXTURE_GEN_Q) .SH SEE ALSO _cmnd(ActiveTextureARB), _cmnd(CopyPixels), _cmnd(CopyTexImage2D), _cmnd(CopyTexSubImage1D), _cmnd(CopyTexSubImage2D), _cmnd(CopyTexSubImage3D), _cmnd(TexEnv), _cmnd(TexImage1D), _cmnd(TexImage2D), _cmnd(TexImage3D), _cmnd(TexParameter), _cmnd(TexSubImage1D), _cmnd(TexSubImage2D), _cmnd(TexSubImage3D)