Ninja Library - Texture Function

njSetTextureParam

Sets texture parameters

FORMAT

void njSetTextureParam( texmemlist )
NJS_TEXMEMLIST *texmemlist

PARAMETER

 texmemlist  Pointer for texture memory list 

RETURN

None

DESCRIPTION

Sets tspparambuffer and texparambuffer for the NJS_TEXMEMLIST structure. The referred data for settings are PixelFormat, nWidth, nHeight, fSurfaceFlags, and pSurface in the NJS_TEXSURFACE structure.


EXAMPLE

One example is the function to forcibly change Mipmap size for display.  
However, only sizes larger than 8 can be displayed (1, 2, 4 cannot be displayed).

If the original value is changed to texinfo below, return to the original value 
when texture is released.  As this sample case has not been changed (it has been copied), 
there is no effect in the original values.

void njSetTextureMipmapSize( NJS_TEXMEMLIST *texmemlist, Uint32 Size )
{
    NJS_TEXMEMLIST tml;

    /* Check Mipmap texture */
    if(texmemlist->texinfo.texsurface.fSurfaceFlags & NJD_SURFACEFLAGS_MIPMAPED){
        /* Decide if the size of the texture is larger than the specified size */
        if(texmemlist->texinfo.texsurface.nWidth >= Size){
            /* Set the size */
            tml.texinfo.texsurface.nWidth = Size;
            tml.texinfo.texsurface.nHeight = Size;
            /* Calculate texture size  The true size is not necessary */
            tml.texinfo.texsurface.TextureSize
                = njCalcTextureSize(Size,Size,tml.texinfo.texsurface.Type >> 16);
            /* Set PixelFormat */
            tml.texinfo.texsurface.PixelFormat = texmemlist->texinfo.texsurface.PixelFormat;
            /* Set offset */
            tml.texinfo.texsurface.pSurface
                = (Uint32*)((Uint32)texmemlist->texinfo.texsurface.pSurface);
            /* Set surface flags */
            tml.texinfo.texsurface.fSurfaceFlags = texmemlist->texinfo.texsurface.fSurfaceFlags;
            /* Set texture parameters texparambuffer, tspparambuffer */
            njSetTextureParam(&tml);
            /* Copy */
            texmemlist->texparambuffer = tml.texparambuffer;
            texmemlist->tspparambuffer = tml.tspparambuffer;
        }
    }
}


NOTE

Be careful when changing data. Return to the original settings when texture is released if NJS_TEXSURFACE structure files are changed.

njSetTextureParam
COPYRIGHT © SEGA ENTERPRISES, LTD., 1998,1999