Ninja Library - テクスチャ関数

njCheckTextureFormatManageNum

テクスチャマネージメント番号によるテクスチャサーフェス情報の設定

書式

Sint32 njCheckTextureFormatManageNum(texmng_no,pvrh)
Sint32 texmng_no
NJS_PVRHEADERDATA *pvrh

引数

texmng_no   テクスチャマネージメント番号
pvrh   NJS_PVRHEADERDATA構造体PVRヘッダデータ

戻り値

 成功
-1   失敗

解説

NJS_PVRHEADERDATA構造体に設定した情報から指定したテクスチャマネージメント番号のテクスチャサーフェス領域にテクスチャサーフェス情報を設定します。

設定されるのは、Type、BitDepth、PixelFormat、nWidth、nHeight、fSurfaceFlags、TextureSizeです。pSurfaceは設定されません。


用例

Sint32 SetTextureManageNum(Uint32 globalIndex,Uint32 bank,NJS_PVRHEADERDATA *pvrh)
{
	Sint32 no;
	Sint32 ret;
	NJS_TEXMANAGE *texmanage;
	NJS_TEXSYSTEM *texsystem;

	
	/* _nj_texsystemから空いているところを探す */
	no = njGetTexManageNum(&texmanage,&texsystem);
	if(no < 0){
		return -1;
	}
	texmanage->texsys = texsystem;

	/* pvrhからサーフェス情報を取得する */
	if(njCheckTextureFormatManageNum(no,pvrh) < 0){
		return -1;
	}
	
	/* ここでtexfixedareaから空いている領域を取得して設定する */
	//texsystem->texsurface.TextureSize ->njCheckTextureFormat関数実行で値は設定されている
	//texsystem->texsurface.pSurface	->この領域にtexfixedareaから取得した領域を設定する

	if((texsystem->texsurface.pSurface = TexMalloc(texsystem->texsurface.TextureSize)) == NULL){
		texmanage->texsys = NULL;
		return -1;
	}
	/******************************************************/
	
	/* グローバルインデックスの設定 */
	if(globalIndex != NJD_GLOBAXINDEX_FIRST_VAL)
		texmanage->texsys->globalIndex = globalIndex;
	
	/* パレットの設定 */
	if(njCheckPaletteType(pvrh->nTextureType)){
		texmanage->bank = bank;
	}
	else{
		texmanage->bank = NJD_BANK_FIRST_VAL;
	}
	
	/* パラメータの設定 */
	njSetTextureParamEx(texmanage);
	texmanage->count = 1;
	texmanage->texsys->count = 1;
	_nj_tex_count++;
	
	return no;
}

備考

この関数は、ユーザーがテクスチャメモリの固定領域を取得した場合など特別な場合しか使用しません。

参照

njTexMallocFixedArea() 固定領域のテクスチャメモリの確保
njTexFreeFixedArea() 固定領域のテクスチャメモリのフリー

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