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>GXColor[n][t]</TITLE>
9</HEAD>
10<BODY>
11<H1 align="left">GXColor</H1>
12
13<H2>Syntax</H2>
14<dl><dd><pre class="construction">
15#include &lt;revolution/gx.h&gt;
16
17void GXColor4u8 ( u8  r, u8  g, u8  b, u8 a );
18
19void GXColor3u8 ( u8  r, u8  g, u8  b );
20
21void GXColor1u32( u32 clr );
22void GXColor1u16( u16 clr );
23
24void GXColor1x16( u16 index );
25void GXColor1x8 ( u8  index );
26</pre></dd></dl>
27
28<H2>Arguments</H2>
29<P>Depends on the function being called.</P>
30
31<H2>Return Values</H2>
32<P>None.</P>
33
34<H2>Description</H2>
35<P>These functions are used to specify color data for a vertex.&nbsp;They can be called only between the <a href="GXBegin.html"><code>GXBegin</code></a> function and the <a href="GXEnd.html"><code>GXEnd</code></a> function.&nbsp;Function names take the following format:</P>
36<P><CODE>GXColor[n][t]</CODE></P>
37<P>&nbsp;</P>
38<P>The <CODE>[n]</CODE> function name parameter has a value of <CODE>1</CODE>, <CODE>3</CODE>, or <CODE>4</CODE>, and indicates the number of arguments to the function. The <code>[t]</code> function name parameter describes the type of each argument to the function and can have a value of <CODE>u8</CODE>, <CODE>u16</CODE>, <CODE>u32</CODE>, <CODE>x8</CODE>, or <CODE>x16</CODE>.&nbsp;The type letter indicates either an unsigned (<CODE>u</CODE>) or index (<code>x</code>) data type. The subsequent number indicates the bit size. For example, <code>u8</code> indicates an unsigned 8-bit data type. For example, the <code>GXColor1u32</code> function takes one unsigned 32-bit argument.</P>
39<P>The selected function must correspond to the current vertex descriptor and the vertex attribute format specified in the <A href="GXBegin.html"><CODE>GXBegin</CODE></A> function.&nbsp;The current vertex descriptor is set using the <A href="GXSetVtxDesc.html"><CODE>GXSetVtxDesc</CODE></A> function.&nbsp;The vertex attribute format is set using the <A href="GXSetVtxAttrFmt.html"><CODE>GXSetVtxAttrFmt</CODE></A> function.</P>
40<P>Vertex functions must be called in the order specified by the <A href="GXSetVtxDesc.html"><CODE>GXSetVtxDesc</CODE></A> function. Each vertex must send attributes (position coordinates, colors, normals, and so forth) in the specified order to guarantee proper parsing by the graphics hardware.</P>
41<P>When an attribute is indexed (meaning its type, set by the <A href="GXSetVtxDesc.html"><CODE>GXSetVtxDesc</CODE></A> function, is <CODE>GX_INDEX8</CODE> or <CODE>GX_INDEX16</CODE>), the vertex function specifies an index to the data, not the data itself. The location of the array that will be indexed is described using the <A href="GXSetArray.html"><CODE>GXSetArray</CODE></A> function. If an attribute is direct (meaning its type, set by the <A href="GXSetVtxDesc.html"><CODE>GXSetVtxDesc</CODE></A> function, is <CODE>GX_DIRECT</CODE>), the vertex function sends the data. No vertex function should be called for an attribute that is disabled (that is, its type, set by the <A href="GXSetVtxDesc.html"><CODE>GXSetVtxDesc</CODE></A> function, is <CODE>GX_NONE</CODE>). However, every vertex must at least enable <CODE>GX_VA_POS</CODE>.</P>
42<P>The <CODE>GXColor[n][t]</CODE> functions are implemented as inline functions in the non-debug version of the GX library for optimal performance. The <CODE>GXColor[n][t]</CODE> functions are implemented as actual functions in the debug version of the GX library so it can verify the correct order of vertex function calls between <A href="GXBegin.html"><CODE>GXBegin</CODE></A> and <A href="GXEnd.html"><CODE>GXEnd</CODE></A> (a common source of errors).</P>
43<P>There is some flexibility in how the <CODE>GXColor[n][t]</CODE> functions are used in relation to the color attribute format.&nbsp;For example, if you want to use 32-bit color per vertex, each function shown below is equally valid.&nbsp;Which one to use will depend on the application.</P>
44<P><CODE>GXColor4u8( 0xff, 0x00, 0xff, 0x80 );<BR> GXColor1u32( 0xff00ff80 );</CODE></P>
45<P>The following macros are provided for packing color data into 16-bit formats:</P>
46<P><CODE><A href="../ColorFormat/GXPackedRGB565.html">GXPackedRGB565</A><BR> <A href="../ColorFormat/GXPackedRGBA4.html">GXPackedRGBA4</A></CODE></P>
47
48<H2>See Also</H2>
49<P class="reference">
50<A href="GXBegin.html">GXBegin</A>,
51<A href="GXEnd.html">GXEnd</A>,
52<A href="GXSetVtxDesc.html">GXSetVtxDesc</A>,
53<A href="GXSetVtxAttrFmt.html">GXSetVtxAttrFmt</A>
54</P>
55
56<H2>Revision History</H2>
57<P>
582006/03/01 Initial version.<br>
59</P>
60
61<hr><p>CONFIDENTIAL</p></body>
62</HTML>