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<h2>Syntax</h2> 17<dl><dd><pre class="construction"> 18#include <revolution/gx.h> 19 20u32 GXGetTexBufferSize( 21 u16 width, 22 u16 height, 23 u32 format, 24 <a href="../Enumerated_Types/GXBool.html">GXBool</a> mipmap, 25 u8 max_lod ); 26</pre></dd></dl> 27 28<h2>Arguments</h2> 29<TABLE class="arguments" border="1" > 30 <tr> 31<TH><CODE>width</CODE></TH> 32<TD>Texture width (in texels)</TD> 33 </tr> 34 <tr> 35<TH><CODE>height</CODE></TH> 36<TD>Texture height (in texels)</TD> 37 </tr> 38 <tr> 39<TH><CODE>format</CODE></TH> 40<TD>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> 41 </tr> 42 <tr> 43<TH><STRONG><EM><CODE>mipmap</CODE></EM></STRONG></TH> 44<TD>Flag indicating that the texture is a mipmap.</TD> 45 </tr> 46 <tr> 47<TH><STRONG><EM><CODE>max_lod</CODE></EM></STRONG></TH> 48<TD>Maximum LOD value.</TD> 49 </tr> 50</TABLE> 51 52<h2>Return Values</h2> 53<p>Number of bytes required for the texture including tile padding.</p> 54 55<H2>Description</H2> 56<P>This is a convenient function that returns the amount of memory in bytes needed to store a texture of the given size and format, <SPAN class="argument">format</SPAN>. If the <SPAN class="argument">mipmap</SPAN> flag is <code>GX_TRUE</code>, then the size of buffer needed for the mipmap pyramid up to <SPAN class="argument">max_lod</SPAN> will be returned. <SPAN class="argument">Max_lod</SPAN> will be clamped to the number of LODs possible given the map <SPAN class="argument">width</SPAN> and <SPAN class="argument">height</SPAN>. For mipmaps, <SPAN class="argument">width</SPAN> and <SPAN class="argument">height</SPAN> must be a power of two.</P> 57<P>This function takes into account the tiling and padding required by the Wii texture format. The resulting size can be used along with the <A href="../../os/Alloc/OSAlloc.html"><CODE>OSAlloc</CODE></A> function to allocate texture buffers.( See <a href="../Framebuffer/GXCopyTex.html"><code>GXCopyTex</code></a>.)</P> 58<DL><DD><CODE>// allocate a non-mipmap buffer<BR> tex_buf = OSAlloc(GXGetTexBufferSize(123, 65, GX_TF_RGB5A3, GX_FALSE, 0));</CODE></DD></DL> 59<DL><DD><CODE>// allocate a mipmap, all LODs<BR> tex_buf = OSAlloc(GXGetTexBufferSize(256, 256, GX_TF_RGB5A3, GX_TRUE, 100));</CODE></DD></DL> 60<DL><DD><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></DD></DL> 61 62<h2>See Also</h2> 63<p>None.</p> 64 65<H2>Revision History</H2> 66<P> 672006/03/01 Initial version.<br> 68</P> 69 70<hr><p>CONFIDENTIAL</p></body> 71</html>