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 http-equiv="Content-Style-Type" content="text/css">
6<LINK rel="stylesheet" type="text/css" href="../CSS/revolution.css">
7<TITLE>FNTTexture</TITLE>
8</HEAD>
9<BODY>
10<H1>FNTTexture</H1>
11
12<H2>Syntax</H2>
13<dl><dd><pre class="construction">
14#include &lt;revolution/fnt.h&gt;
15
16typedef struct
17{
18    void*       image;
19    s8          left;
20    u8          glyphWidth;
21    s8          charWidth;
22    u8          charHeight;
23    <A href="../gx/Enumerated_Types/GXTexFmt.html">GXTexFmt</A>    texFormat;
24    u16         texWidth;
25    u16         texHeight;
26    u16         cellX;
27    u16         cellY;
28} FNTTexture;
29</pre></dd></dl>
30
31<H2>Elements</H2>
32<TABLE class="arguments" border="1" >
33  <TBODY>
34    <TR>
35<TH>image</TH>
36<TD width="87%">Pointer to a texture image sheet.</TD>
37    </TR>
38    <TR>
39<TH>left</TH>
40<TD>Left space width of the character (in texels).</TD>
41    </TR>
42    <TR>
43<TH>glyphWidth</TH>
44<TD>Text glyph width (in texels). (A glyph is the visually recognizable shape of a character.)</TD>
45    </TR>
46    <TR>
47<TH>charWidth</TH>
48<TD>Character width (=left space width + glyph width + right space width) in texels.</TD>
49    </TR>
50    <TR>
51<TH>charHeight</TH>
52<TD>Font height (in texels).</TD>
53    </TR>
54    <TR>
55<TH>texFormat</TH>
56<TD>Format of the texture image sheet.</TD>
57    </TR>
58    <TR>
59<TH>texWidth</TH>
60<TD>Texture image sheet width (in texels).</TD>
61    </TR>
62    <TR>
63<TH>texHeight</TH>
64<TD>Texture image sheet height (in texels).</TD>
65    </TR>
66    <TR>
67<TH>cellX</TH>
68<TD>Horizontal coordinate of a character in the texture image sheet.</TD>
69    </TR>
70    <TR>
71<TH>cellY</TH>
72<TD>Vertical coordinate of a character in the texture image sheet.</TD>
73    </TR>
74  </TBODY>
75</TABLE>
76
77<H2>Description</H2>
78<P>This structure stores texture information used to draw a single character using the font.</P>
79<P>An example of code that loads the texture according to information in the <CODE>FNTTexture</CODE> structure and draws the associated polygons is given below.</P>
80<BLOCKQUOTE>
81<PRE><CODE>void DrawCharacter( f32 x, f32 y, f32 z, const FNTTexture* tex )
82{
83    f32 posLeft   = x + tex-&gt;left;
84    f32 posTop    = y;
85    f32 posRight  = posLeft + tex-&gt;glyphWidth;
86    f32 posBottom = posTop  + tex-&gt;charHeight;
87    f32 texLeft   = (f32)tex-&gt;cellX / tex-&gt;texWidth;
88    f32 texTop    = (f32)tex-&gt;cellY / tex-&gt;texHeight;
89    f32 texRight  = (f32)(tex-&gt;cellX + tex-&gt;glyphWidth) / tex-&gt;texWidth;
90    f32 texBottom = (f32)(tex-&gt;cellY + tex-&gt;charHeight) / tex-&gt;texHeight;
91    GXTexObj tobj;
92
93    GXInitTexObj(&amp;tobj, tex-&gt;image, tex-&gt;texWidth, tex-&gt;texHeight,
94        tex-&gt;texFormat, GX_CLAMP, GX_CLAMP, GX_FALSE);
95    GXInitTexObjLOD(&amp;tobj, GX_LINEAR, GX_LINEAR, 0, 0, 0,
96        GX_DISABLE, GX_DISABLE, GX_ANISO_1);
97    GXLoadTexObj(&amp;tobj, GX_TEXMAP0);
98
99    GXBegin(GX_QUADS, GX_VTXFMT0, 4);
100    {
101        GXPosition3f32(posLeft, posTop, z);
102        GXTexCoord2f32(texLeft, texTop);
103
104        GXPosition3f32(posRight, posTop, z);
105        GXTexCoord2f32(texRight, texTop);
106
107        GXPosition3f32(posRight, posBottom, z);
108        GXTexCoord2f32(texRight, texBottom);
109
110        GXPosition3f32(posLeft, posBottom, z);
111        GXTexCoord2f32(texLeft, texBottom);
112    }
113    GXEnd();
114}</PRE></CODE>
115</BLOCKQUOTE>
116
117<H2>See Also</H2>
118<P class="reference">
119<A href="FNTGetTexture.html">FNTGetTexture</A>
120</P>
121
122<H2>Revision History</H2>
123<P>
1242006/10/01 Initial version.<BR>
125</P>
126
127<hr><p>CONFIDENTIAL</p></body>
128</HTML>