1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3
4<head>
5<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
6<META name="GENERATOR" content="Microsoft FrontPage 5.0">
7<META http-equiv="Content-Style-Type" content="text/css">
8<LINK rel="stylesheet" type="text/css" href="../../CSS/revolution.css">
9<title>GXGetTexBufferSize</title>
10</head>
11
12<body>
13
14<h1 align="left">GXGetTexBufferSize</h1>
15
16
17<h2>C Specification</h2>
18
19<dl>
20<dd><PRE><CODE>#include &lt;revolution/gx.h&gt;</CODE></PRE>
21  </dd>
22<dd><pre><CODE>u32 GXGetTexBufferSize(
23u16       width,
24u16       height,
25u32       format,
26<a href="../Enumerated_Types/GXBool.html">GXBool</a>    mipmap,
27u8        max_lod );</CODE></pre>
28  </dd>
29</dl><h2>Arguments</h2>
30<TABLE border="1" cellpadding="3" cellspacing="0.1">
31  <tr>
32<TD width="120" valign="top" bgcolor="#ffffe8"><em><strong><CODE>width</CODE></strong></em></TD>
33<TD width="520">Texture width (in texels).</TD>
34    </tr>
35  <tr>
36<TD width="120" valign="top" bgcolor="#ffffe8"><em><strong><CODE>height</CODE></strong></em></TD>
37<TD width="520">Texture height (in texels).</TD>
38    </tr>
39  <tr>
40<TD width="120" valign="top" bgcolor="#ffffe8"><em><strong><CODE>format</CODE></strong></em></TD>
41<TD width="520">Texture format. Select either <A href="../Enumerated_Types/GXTexFmt.html"><CODE>GXTexFmt</CODE></A> or <A href="../Enumerated_Types/GXCITexFmt.html"><CODE>GXCITexFmt</CODE></A>.</TD>
42    </tr>
43  <tr>
44<TD width="120" valign="top" bgcolor="#ffffe8"><em><strong><CODE>mipmap</CODE></strong></em></TD>
45<TD width="520">Flag indicating that the texture is a mipmap.</TD>
46    </tr>
47</TABLE>
48<h2>Return Values</h2>
49
50<p>Number of bytes required for the texture including tile padding.</p>
51<H2>Description</H2>
52<P>This is a convenient function that returns the amount of memory in bytes needed to store a texture of the given size and <em><strong><code>format</code></strong></em>. If the <code><em><strong>mipmap</strong></em></code> flag is <code>GX_TRUE</code>, then the size of buffer needed for the mipmap pyramid up to <em><strong><code>max_lod</code></strong></em> will be returned.&nbsp;<em><strong><code>Max_lod</code></strong></em> will be clamped to the number of LODs possible given the map <em><strong><code>width</code></strong></em> and <em><strong><code>height</code></strong></em>. For mipmaps, <code><em><strong>width</strong></em></code> and <code><em><strong>height</strong></em></code> must be a power of two.</P>
53<P>This function takes into account the tiling and padding required by the Revolution texture format.&nbsp;The resulting size can be used along with <a href="../../os/Alloc/OSAlloc.html"><code>OSAlloc</code></a> to allocate texture buffers,(see <a href="../Framebuffer/GXCopyTex.html"><code>GXCopyTex</code></a>.)</P>
54<P><font size="3"><code>// allocate a non-mipmap buffer<br> tex_buf = OSAlloc(GXGetTexBufferSize(123, 65, GX_TF_RGB5A3, GX_FALSE, 0));</code></font></P>
55<P><font size="3"><code>// allocate a mipmap, all LODs<br> tex_buf = OSAlloc(GXGetTexBufferSize(256, 256, GX_TF_RGB5A3, GX_TRUE, 100));</code></font></P>
56<P><font size="3"><code>// determine the address of LOD 3<br> size = GXGetTexBufferSize(256, 256, GX_TF_RGB5A3, GX_TRUE, 3);<br> lod_3_addr = tex_buf + size;</code></font></P>
57
58<h2>See Also</h2>
59<H2>Revision History</H2>
60<P>03/01/2006 Initial version.</P></body>
61</html>