Ninja Library - テクスチャ関数

njSetTextureParamEx

テクスチャパラメータの設定

書式

void njSetTextureParamEx( texmanage )
NJS_TEXMANAGE *texmanage

引数

texmanage   テクスチャマネージメント構造体のポインタ

戻り値

なし

解説

NJS_TEXMANAGE構造体のtspparamとtexparamを設定します。

設定時に参照されるデータはNJS_TEXSURFACE構造体のPixelFormat、nWidth、nHeight、fSurfaceFlags、pSurfaceです。


用例

Mipmapのサイズを強引に変えて表示する関数の例です。
ただし8以上だけです(1,2,4は表示できない)
元の値からtexinfo以下を変更する場合はテクスチャを
リリースするときに元に戻してください。
このサンプルの場合は変更していないので
(コピーしているので)関係ありません。

void njSetTextureMipmapSize( NJS_TEXMANAGE *texmanage, Uint32 Size )
{
	NJS_TEXMANAGE tmg;
	NJS_TEXSYSTEM tsy;
	if(texmanage->texsys == NULL)	return;
	/* Check Mipmap texture */
	if(texmanage->texsys->texsurface.fSurfaceFlags
		& NJD_SURFACEFLAGS_MIPMAPED){
		/* Decide if the size of the texture 
			is larger than the specified size */
		if(texmanage->texsys->texsurface.nWidth >= Size){
			/* Set the size */
			tmg.texsys = &tsy;
			tmg.texsys->texsurface.nWidth = Size;
			tmg.texsys->texsurface.nHeight = Size;

			/* Calculate texture size  
	  		 The true size is not necessary */
			tmg.texsys->texsurface.TextureSize
				 = njCalcTextureSize(Size,Size,
	 		  tmg.texsys->texsurface.Type >> 16);

			/* Set PixelFormat */
			tmg.texsys->texsurface.PixelFormat
	 			= texmanage->texsys->texsurface.PixelFormat;

			/* Set offset */
			tmg.texsys->texsurface.pSurface
	 			= (Uint32*)((Uint32)texmanage->texsys->texsurface.pSurface);

			/* Set surface flags */
			tmg.texsys->texsurface.fSurfaceFlags
				= texmanage->texsys->texsurface.fSurfaceFlags;

			/* Set texture parameters texparambuffer, 
				tspparambuffer */
			njSetTextureParamEx(&tmg);

			/* Copy */
			texmanage->texparam = tmg.texparam;
			texmanage->tspparam = tmg.tspparam;
		}
	}
}

備考

データを変更するときは注意が必要です。 NJS_TEXSURFACE構造体のメンバを変更した場合、テクスチャリリース時には元に戻してください。

njSetTextureParamEx
COPYRIGHT © SEGA ENTERPRISES, LTD., 1998-2000