guLoadTextureBlockMipMap
Creates MIP map texture and display list
#include <ultra64.h> /* gu.h */ int guLoadTextureBlockMipMap( Gfx **glist, unsigned char *tbuf, Image *im, unsigned char startTile, unsigned char pal, unsigned char cms, unsigned char cmt, unsigned char masks, unsigned char maskt, unsigned char shifts, unsigned char shiftt, unsigned char cfs, unsigned char cft);
Termination flag
|
This function calculates a MIP map pyramid from the source texture array, and returns to glist the display list that is needed for loading and rendering of the MIP map texture. Texture images are extracted from system memory and the MIP map pyramid is created in tbuf. Each level of the pyramid is created from the previous level by filtering using a box filter. The display list for loading the tiles and setting the tile parameters is inserted into the display list specified by glist.
The MIP map texture must be smaller than the size of TMEM.
The alpha channel is used for trees and other cutout-like textures. Note that the cutout shapes of the MIP map textures used by the alpha channel will change, depending on the LOD. This is especially prone to happen with 1-bit alpha texel formats (i.e., RGBA16, IA4, etc.)
The Image structure is shown below:
typedef struct {
unsigned char *base;
int fmt, siz; // Texture image format, pixel component size
int xsize, ysize; // x,y size of source image
int lsize; // Line size of source image
/* Current tile information */
int addr; // Storage buffer offset ( = 0)
int w, h; // Width, height of rectangular section of image (tile)
int s, t; // s,t offset of source image
} Image;
The following is for a 32 x 32 16-bit RGBA source image
im->base = (unsigned char *)&RGBA16grid_32[0];
im->fmt = G_IM_FMT_RGBA;
im->siz = G_IM_SIZ_16b;
/* source image 'x' size */
im->xsize= 32;
/* source image 'y' size */
im->ysize= 32;
/* size of a source image row */
im->lsize= 32* sizeof(unsigned short);
/* offset into storage buffer. Must be zero */
im->addr = 0;
/* width of rectangular section of image(tile) to be extracted for MIP mapping Extract for MIP mapping */
im->w = 32;
/* height of rectangular section of image to be extracted for MIP mapping */
im->h = 32;
/* 's' and 't' offsets into source image to */
im->s = 0;
/* Define rectangular tile */
im->t = 0;
03/01/99 Completely rewritten