Ninja Library - テクスチャ関数

njLoadTexturePartLowEx

即時復帰型ローレベル分割テクスチャロード

書式

Sint32 njLoadTexturePartLowEx( texmanage, pTexture, offset, size )
NJS_TEXMANAGE *texmanage
Uint32 *pTexture
Uint32 offset
Uint32 size

引数

texmanage   テクスチャマネージメント構造体のポインタ
pTexture   テクスチャデータのアドレス
offset   テクスチャデータ先頭からのオフセット(バイト)
size   ロードサイズ(バイト)

戻り値

成功   1
失敗   -1

解説

テクスチャデータの先頭アドレス+offsetバイトの位置からsizeバイトのロード要求を行います。

テクスチャサイズ以上のロード要求があっても、そのサイズ以上ロードすることはありません。 pTextureのアドレスが32バイトアラインメントかつoffsetが32の倍数のときsizeの32の倍数分は 即時復帰し、残りを完了復帰します。ロードの終了はnjLoadTextureFinishDMA()関数で確認してください。


用例

void FreeTexManage(NJS_TEXMANAGE *texmanage);

/* 簡単なロード関数の例 (メモリにヘッダ付きテクスチャがある場合)*/
Sint32 EasyLoadTexture(NJS_TEXLIST *texlist,Uint32 n,Sint8 *pTexture)
{
    NJS_TEXMANAGE *texmanage;
    NJS_TEXSYSTEM *texsystem;
    Uint32 globalIndex;
    NJS_PVRHEADERDATA pvrh;
    Uint32 *data;
    Uint32 size;
    Sint32 texmng_no;
    /*
    データにはグローバルインデックス、
    PVRヘッダデータがあるものとする
    */
    if((data = njLoadPvrHeader(&pvrh,&globalIndex,pTexture))== NULL){
    /* ヘッダがなかった場合*/
        return -1;
    }

    /* テクスチャマネージメント構造体の空きを取得 */
	texmng_no = njGetTexManageNum(&texmanage,&texsystem);
    
	if(texmng_no < 0){
		return -1;
	}
	texmanage->texsys = texsystem;
    
	/* サーフェスの取得 */
	ret = njGetTexSurfaceEx(texmanage,pvrh);
	if(ret != 1) {
		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++;

    /* データ先頭からサイズ分ロードする*/
    size = texmanage->texsys->texsurface.TextureSize;
    if(njLoadTexturePartLowEx(texmanage,data,0,size)== -1){
        /* サーフェスのリリース*/
        njReleaseTextureLowEx(texmanage);
        FreeTexManage(texmanage);
        return -1;
    }
    
    /* DMA終了まで待つ*/
    while(njLoadTextureFinishDMA() != 1);

    /* テクスチャリストとテクスチャメモリリストのリンクをはる */ 
	njLinkTexlist(texlist,n,texmng_no);
	
    return 1;
}

/* 
	テクスチャマネージメント構造体の開放設定
	njClearTextureSurface関数と同じ機能
*/
void FreeTexManage(NJS_TEXMANAGE *texmanage)
{
	NJS_TEXSYSTEM *texsys;
	
	texsys = texmanage->texsys;
	if(texsys != NULL){
		texsys->globalIndex = NJD_GLOBAXINDEX_FIRST_VAL;
	    texsys->texsurface.Type = 0;
		texsys->texsurface.BitDepth = 0;
		texsys->texsurface.PixelFormat = 0;
		texsys->texsurface.nWidth = 0;
		texsys->texsurface.nHeight = 0;
		texsys->texsurface.TextureSize = 0;
		texsys->texsurface.fSurfaceFlags = 0;
		texsys->texsurface.pSurface = 0;
		texsys->count = 0;
	}
    texmanage->bank = NJD_BANK_FIRST_VAL;
    texmanage->tspparam = 0;
    texmanage->texparam = 0;
    texmanage->texsys = NULL;
	texmanage->texflag = 0;
	texmanage->count = 0;

}


備考

使用する場合、他のテクスチャ関数との互換に注意してください。

参照

njLoadPvrHeader() PVRヘッダデータの取得
njGetTexSurfaceEx() テクスチャサーフェスの作成
njLoadTextureFinishDMA() テクスチャのDMA終了確認
njReleaseTextureLowEx() テクスチャローレベルリリース

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