1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<HTML>
3<HEAD>
4<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
5<META name="GENERATOR" content="Microsoft FrontPage 5.0">
6<META http-equiv="Content-Style-Type" content="text/css">
7<LINK rel="stylesheet" type="text/css" href="../../CSS/revolution.css">
8<TITLE>GXSetTevColorOp</TITLE>
9</HEAD>
10<BODY>
11<H1 align="left">GXSetTevColorOp</H1>
12<H2>C Specification</H2>
13<DL>
14  <DD>
15<PRE><CODE>#include &lt;revolution/gx.h&gt;</CODE></PRE>
16  <DD>
17<PRE><CODE>void GXSetTevColorOp(
18<a href="../Enumerated_Types/GXTevStageID.html">GXTevStageID</a>    stage,
19<a href="../Enumerated_Types/GXTevOp.html">GXTevOp</a>         op,
20<a href="../Enumerated_Types/GXTevBias.html">GXTevBias</a>       bias,
21<a href="../Enumerated_Types/GXTevScale.html">GXTevScale</a>      scale,
22<a href="../Enumerated_Types/GXBool.html">GXBool</a>          clamp,
23<a href="../Enumerated_Types/GXTevRegID.html">GXTevRegID</a>      out_reg );</CODE></PRE>
24</DL>
25<H2>Arguments</H2>
26<TABLE border="1" cellspacing="0.1" cellpadding="3">
27  <TBODY>
28    <TR>
29<TD width="120" valign="top" bgcolor="#ffffe8"><EM><STRONG><CODE>stage</FONT></STRONG></EM></TD>
30<TD width="520">The TEV stage <a href="../Enumerated_Types/GXTevStageID.html">name</a>. <BR>Accepted values are: <code>GX_TEVSTAGE0</code>, <code>GX_TEVSTAGE1</code>, <code>GX_TEVSTAGE2</code> through <code>GX_TEVSTAGE15</code>.</TD>
31    </TR>
32    <TR>
33<TD width="120" valign="top" bgcolor="#ffffe8"><EM><STRONG><CODE>op</FONT></STRONG></EM></TD>
34<TD width="520">TEV <a href="../Enumerated_Types/GXTevOp.html">operation</a>. <BR>Accepted values are:<BR>
35      <TABLE border="1" width="500" cellspacing="0.1">
36
37          <tr>
38<TD width="150" bgcolor="#C0C0C0">Name</TD>
39<TD width="350" bgcolor="#C0C0C0">Equation</TD>
40          </tr>
41          <tr>
42<TD width="150"><code>GX_TEV_ADD</code></TD>
43<TD width="350"><code><em>(d + ((1.0 - c)*a + c*b) + bias) * scale;</em></code></TD>
44          </tr>
45          <tr>
46<TD width="150"><code>GX_TEV_SUB</code></TD>
47<TD width="350"><code><em>(d - ((1.0 - c)*a + c*b) + bias) * scale;</em></code></TD>
48          </tr>
49          <tr>
50<TD width="150"><code>GX_TEV_COMP_R8_GT</code></TD>
51<TD width="350"><code><em>d + ((a[R] &gt; b[R]) ? c : 0 );</em></code></TD>
52          </tr>
53          <tr>
54<TD width="150"><code>GX_TEV_COMP_R8_EQ </code></TD>
55<TD width="350"><code><em>d + ((a[R] == b[R]) ? c : 0 );</em></code></TD>
56          </tr>
57          <tr>
58<TD width="150"><code>GX_TEV_COMP_GR16_GT</code></TD>
59<TD width="350"><code><em>d + ((a[GR] &gt; b[GR]) ? c : 0 );</em></code></TD>
60          </tr>
61          <tr>
62<TD width="150"><code>GX_TEV_COMP_GR16_EQ</code></TD>
63<TD width="350"><code><em>d + ((a[GR] == b[GR]) ? c : 0 );</em></code></TD>
64          </tr>
65          <tr>
66<TD width="150"><code>GX_TEV_COMP_BGR24_GT</code></TD>
67<TD width="350"><code><em>d + ((a[BGR] &gt; b[BGR]) ? c : 0 );</em></code></TD>
68          </tr>
69          <tr>
70<TD width="150"><code>GX_TEV_COMP_BGR24_EQ</code></TD>
71<TD width="350"><code><em>d + ((a[BGR] == b[BGR]) ? c : 0 );</em></code></TD>
72          </tr>
73          <tr>
74<TD width="150"><code>GX_TEV_COMP_RGB8_GT</code></TD>
75<TD width="350"><code><em>R: d[R] + ((a[R] &gt; b[R]) ? c[R] :0 );<br> G: d[G] + ((a[G] &gt; b[G]) ? c[G] :0 );<br> B: d[B] + ((a[B] &gt; b[B]) ? c[B] : 0 );</em></code></TD>
76          </tr>
77          <tr>
78<TD width="150"><code>GX_TEV_COMP_RGB8_EQ</code></TD>
79<TD width="350"><code><em>R: d[R] + ((a[R] == b[R]) ? c[R] :0 );<br> G: d[G] + ((a[G] == b[G]) ? c[G] :0 );<br> B: d[B] + ((a[B] == b[B]) ? c[B] : 0 );</em></code></TD>
80          </tr>
81
82      </TABLE>
83      </TD>
84    </TR>
85    <TR>
86<TD width="120" valign="top" bgcolor="#ffffe8"><EM><STRONG><CODE>add_bias</FONT></STRONG></EM></TD>
87<TD width="520">Bias <a href="../Enumerated_Types/GXTevBias.html">value</a>.&nbsp;<BR>Accepted values are:<BR>
88      <TABLE border="1" width="500" cellspacing="0.1">
89
90          <tr>
91<TD width="150" bgcolor="#C0C0C0">Name</TD>
92<TD width="350" bgcolor="#C0C0C0">bias value</TD>
93          </tr>
94          <tr>
95<TD width="150"><code>GX_TB_ZERO</code></TD>
96            <TD width="350">0</TD>
97          </tr>
98          <tr>
99<TD width="150"><code>GX_TB_ADDHALF</code></TD>
100            <TD width="350">0.5 (128)</TD>
101          </tr>
102          <tr>
103<TD width="150"><code>GX_TB_SUBHALF</code></TD>
104            <TD width="350">-0.5 (-128)</TD>
105          </tr>
106
107      </TABLE>
108Note that the bias works only when <strong><em><CODE>op</code></em></strong> is set to <code>GX_TEV_ADD</code> or <code>GX_TEV_SUB</code>. Otherwise this argument must be always set to <code>GX_TB_ZERO</code>.</TD>
109    </TR>
110    <TR>
111<TD width="120" valign="top" bgcolor="#ffffe8"><EM><STRONG><CODE>scale</FONT></STRONG></EM></TD>
112<TD width="520">Scale <a href="../Enumerated_Types/GXTevScale.html">value</a>.&nbsp;<BR>Accepted values are:<BR>
113      <TABLE border="1" width="500" cellspacing="0.1">
114
115          <tr>
116<TD width="150" bgcolor="#C0C0C0">Name</TD>
117<TD width="350" bgcolor="#C0C0C0">scale value</TD>
118          </tr>
119          <tr>
120<TD width="150"><code>GX_CS_SCALE_1</code></TD>
121            <TD width="350">1</TD>
122          </tr>
123          <tr>
124<TD width="150"><code>GX_CS_SCALE_2</code></TD>
125            <TD width="350"> 2</TD>
126          </tr>
127          <tr>
128<TD width="150"><code>GX_CS_SCALE_4</code></TD>
129            <TD width="350"> 4</TD>
130          </tr>
131          <tr>
132<TD width="150"><code>GX_CS_DIVIDE_2</code></TD>
133            <TD width="350"> 1/2</TD>
134          </tr>
135
136      </TABLE>
137      </TD>
138    </TR>
139    <TR>
140<TD width="120" valign="top" bgcolor="#ffffe8"><EM><STRONG><CODE>clamp</FONT></STRONG></EM></TD>
141<TD width="520">Clamp results when <code>GX_TRUE</code>.&nbsp;The range becomes 0.0 to 1.0 (0 to 255) after clamping.</TD>
142    </TR>
143    <TR>
144<TD width="120" valign="top" bgcolor="#ffffe8"><EM><STRONG><CODE>out_reg</FONT></STRONG></EM></TD>
145<TD width="520">Output register <a href="../Enumerated_Types/GXTevRegID.html">name</a>. Accepted values are: <code>GX_TEVPREV</code>, <code>GX_TEVREG0</code>, <code>GX_TEVREG1</code>, <code>GX_TEVREG2</code>. The last active Tev stage must write <code>GX_TEVPREV</code>.</TD>
146    </TR>
147  </TBODY>
148</TABLE>
149<H2>Return Values</H2>
150<P>None</P>
151<H2>Description</H2>
152<P>This function sets the <code><em><strong>op</strong></em></code>, <code><em><strong>scale</strong></em></code>, <code><em><strong>bias</strong></em></code>, and <em><code><strong>clamp</strong></code></em>ing operation for the color combiner function for this <code><em><strong>stage</strong></em></code> of the Texture Environment (TEV) unit. This function also specifies the output register, <code><em><strong>out_reg</strong></em></code>, that will contain the result of the color combiner function.&nbsp;The color combiner function is:</P>
153<P><font size="3"><code><em><strong>out_reg</strong> = (d (<strong>op</strong>) ((1.0 - c)*a + c*b) + <strong>bias</strong>) * <strong>scale</strong>;</em></code></font></P>
154<P>The input parameters <em><code>a</code>, <code>b</code>, <code>c</code><strong>,</strong></em> and <code><em>d</em></code> are selected using the <code><a href="GXSetTevColorIn.html">GXSetTevColorIn</a></code> function.  The <em><code>a</code>, <code>b</code>,</em> and <code><em>c</em></code> inputs are unsigned 8b inputs <em><code>(0 &lt;= a,b,c &lt;= 255)</code></em>.&nbsp;The <em><code>d</code></em>input is a signed 10b input <em><code>(-1024 &lt;= d &lt;= 1023)</code></em>.&nbsp;The result, <code><em><strong>out_reg</strong></em></code>, can also be a signed 10-bit result, depending on the <code><em><strong>clamp</strong></em></code> enable and the current clamping mode,</P>
155<P>The TEV output registers are shared among all the TEV stages.&nbsp;The TEV output registers can also be used as constant color inputs, so the application should be careful to allocate input and ouput registers so no collision occurs when implementing a particular equation.&nbsp;The application must output to <code>GX_TEVPREV</code> in the last active TEV stage.</P>
156<P>The function <a href="GXSetTevOp.html"><code>GXSetTevOp</code></a> provides a simpler way to set the parameters of <a href="GXSetTevColorIn.html"><code>GXSetTevColorIn</code></a> and <a href="GXSetTevColorIn.html"><code>GXSetTevColorOp</code></a> based on predefined equation names.&nbsp;You should not mix usage of <a href="GXSetTevOp.html"><code>GXSetTevOp</code></a> and <code><a href="GXSetTevColorIn.html">GXSetTevColorIn</a>/<a href="GXSetTevColorOp.html">GXSetTevColorOp</a></code>. <a href="GXSetTevOp.html"><code>GXSetTevOp</code></a> makes some assumptions about the output register usage, namely that <a href="../Enumerated_Types/GXTevRegID.html"><code>GX_TEVPREV</code></a> is always the output register and is used to pass the result of the previous TEV stage to the next TEV stage.</P>
157<H2>See Also</H2>
158<H2>Revision History</H2>
159<P>03/01/2006 Initial version.</P>