예제 #1
0
//---テクスチャーをロードする
int eiTextureCell::Load(int trans /*= 1*/)
{
	int surface_color = TextureSurfaceColor;

	if(!Data.CreateFlag){
		eiDebugWriteFile("(eiTextureCell) Not Created!!\n");
		return 0;
	}

	eiDDSurface TempSurface;

	//---テクスチャーサーフェイスを確保
	if(!CreateSurface()){
		return 0;
	}
	Texture.SetSrcBltColorKey(16,16);
//	eiDebugWriteFile("(eiTextureCell) Texture.Create Succes\n");

	//---エミュレーションでなければテンポラリサーフェイスを作る
	if(!TempSurface.Create(Data.xSize,Data.ySize,
		ESCREATE_TEXTURE | ESCREATE_TEMPTEXTURE | ESCREATE_SYSTEMMEMORY,
		&Texture,TextureSurfaceColor)){
		Texture.Release();
		eiDebugWriteFile("::::::::::::1\n");
		return 0;
	}
//	eiDebugWriteFile("(eiTextureCell) TempSurface.Create Succes\n");

	if(Data.Color <= 8 && TempSurface.Color <= 8){
		//---パレット
		if(CreatePalette()){
			TempSurface.lpSurface->SetPalette(Palette.lpPalette);
			Texture.lpSurface->SetPalette(Palette.lpPalette);
		}
	}

	//---テンポラリサーフェイスへコピーする
	dib.CopyToDDSurface(&TempSurface,0,0,NULL,trans);
//	eiDebugWriteFile("(eiTextureCell) dib.CopyToDDSurface end\n");

	RECT rect = {0,0,Data.xSize,Data.ySize};

	if(!LoadFromSurface(&TempSurface,&rect)){
		eiDebugWriteFile("(eiTextureCell) load fail\n");
	}

	//---いらなくなったのを解放
	TempSurface.Release();

	//---サーフェイスセット
	Data.SurfaceFlag = 1;
	Data.SurfaceNumber = 2;
	pDDSurface = &Texture;

//	eiDebugWriteFile("(eiTextureCell) Create succes\n");

	return 1;
}
예제 #2
0
int eiTextureCell::CreateFromSurface(int sx,int sy,int color,eiDDSurface *pSurface,RECT *pSrcRect)
{
	CreateTexture(sx,sy,color);
	CreateSurface();
	if(Data.Color <= 8){//TextureSurfaceColor/*8*/){
		if(CreatePalette()){
			Texture.lpSurface->SetPalette(Palette.lpPalette);
		}
	}

	return LoadFromSurface(pSurface,pSrcRect);
}
예제 #3
0
//---------------------------------------
bool Texture2D::Load()
{
	if ( !mIsLoaded )
	{
		SDL_Surface* surf = IMG_Load( mFilename.c_str() );

		// Failed to load - see if we can recover
		if ( !surf )
		{
			// Check the extension
			std::string extension = StringUtil::GetFileExtension( mFilename );
			// Try to guess it if it is missing
			if ( extension.empty() )
			{
				surf = GuessExtension( mFilename );
			}

			if ( !surf )
			{
				WarnInfo( "Bad Texture Path '%s' : Searching for texture...\n", mFilename.c_str() );
				// Try the default data folder
				std::string path = "../data/";
				std::string fileWithoutPath = StringUtil::ExtractFilenameFromPath( mFilename );
				// Try to guess it if it is missing
				if ( extension.empty() )
				{
					surf = GuessExtension( path + fileWithoutPath );
				}
				else
				{
					surf = IMG_Load( ( path + fileWithoutPath ).c_str() );
				}
			}
		}

		if ( LoadFromSurface( surf ) )
		{
			SDL_FreeSurface( surf );

			mIsLoaded = true;
		}
	}
	if ( !mIsLoaded )
	{
		WarnFail( "Failed to load image '%s'\n", mFilename.c_str() );
	}
	return mIsLoaded;
}
예제 #4
0
//---------------------------------------
Texture2D::Texture2D( SDL_Surface* surf )
	: mIsLoaded( true )
{
	LoadFromSurface( surf );
}