当前位置: 首页>>代码示例>>C++>>正文


C++ ITexture::Unlock方法代码示例

本文整理汇总了C++中ITexture::Unlock方法的典型用法代码示例。如果您正苦于以下问题:C++ ITexture::Unlock方法的具体用法?C++ ITexture::Unlock怎么用?C++ ITexture::Unlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITexture的用法示例。


在下文中一共展示了ITexture::Unlock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:


//.........这里部分代码省略.........
		rectT.top = H;
		rectT.bottom = H + EXPAND_TEXTURE_SIZE;
		rectT.left = W;
		rectT.right = W + EXPAND_TEXTURE_SIZE;
		pTerrain->m_pTerrainTexture->Lock(0,&lockT,&rectT,0,LOCK_DISCARD);
		pTexture->Lock(0,&lockO,&rectO,0,LOCK_READONLY);
		//pTerrain->pTar = (TCHAR*)lockT.pBits;
		TCHAR* pTar = (TCHAR*)lockT.pBits;
		TCHAR* pOrc = (TCHAR*)lockO.pBits;

		for (UINT i=0;i<EXPAND_SIZE;++i,pTar+=lockT.Pitch)
		{
			for ( UINT j=0;j<EXPAND_SIZE;++j)
			{
				memcpy(pTar+PixelSize*j,pOrc,PixelSize);
				memcpy(pTar+lockO.Pitch+PixelSize*(j+EXPAND_SIZE),pOrc+lockO.Pitch-PixelSize,PixelSize);
			}
			memcpy(pTar+PixelSize*EXPAND_SIZE,pOrc,lockO.Pitch);
		}

		for (UINT i = 0;i<TEXTURE_SIZE;++i,pTar+=lockT.Pitch,pOrc+=lockO.Pitch)
		{

			for ( UINT j=0;j<EXPAND_SIZE;++j)
			{
				memcpy(pTar+PixelSize*j,pOrc,PixelSize);
				memcpy(pTar+lockO.Pitch+PixelSize*(j+EXPAND_SIZE),pOrc+lockO.Pitch-PixelSize,PixelSize);
			}
			memcpy(pTar+PixelSize*EXPAND_SIZE,pOrc,lockO.Pitch);
		}
		pOrc-=lockO.Pitch;
		for (UINT i=0;i<EXPAND_SIZE;++i,pTar+=lockT.Pitch)
		{
			for ( UINT j=0;j<EXPAND_SIZE;++j)
			{
				memcpy(pTar+PixelSize*j,pOrc,PixelSize);
				memcpy(pTar+lockO.Pitch+PixelSize*(j+EXPAND_SIZE),pOrc+lockO.Pitch-PixelSize,PixelSize);
			}
			memcpy(pTar+PixelSize*EXPAND_SIZE,pOrc,lockO.Pitch);
		}

		pTexture->Unlock(0);
		pTerrain->m_pTerrainTexture->Unlock(0);
	}

	///删掉载入不成功的纹理列表
	set<string>::iterator erroriter = erroTexList.begin();
	set<string>::iterator eeiter = erroTexList.end();
	map<string, DWORD>::iterator fiter;
	map<string, DWORD>::iterator feiter = pRender->m_TerrainTexIndexs.end();
	for (erroriter; erroriter != eeiter; ++erroriter)
	{
		texname = *erroriter;

		fiter = pRender->m_TerrainTexIndexs.find(texname);

		if ( fiter != feiter )
			pRender->m_TerrainTexIndexs.erase(fiter);
	}

	int nGridCnt = pTerrain->GetGridCount();
	string gridtexname = "";
	for ( int i = 0; i < nGridCnt; ++i )
	{
		SGrid &Grid = pTerrain->GetGrid(i);

		gridtexname = Grid.nodeInfo.strTextureNames[0];
		erroriter = erroTexList.find(gridtexname);
		if (erroriter != eeiter)
			Grid.nodeInfo.strTextureNames[0] = "";

		gridtexname = Grid.nodeInfo.strTextureNames[1];
		erroriter = erroTexList.find(gridtexname);
		if (erroriter != eeiter)
			Grid.nodeInfo.strTextureNames[1] = "";

		gridtexname = Grid.nodeInfo.strTextureNames[2];
		erroriter = erroTexList.find(gridtexname);
		if (erroriter != eeiter)
			Grid.nodeInfo.strTextureNames[2] = "";
	}
	texCnt = 0;
	map<string, DWORD>::iterator titer = pRender->m_TerrainTexIndexs.begin();
	map<string, DWORD>::iterator teiter = pRender->m_TerrainTexIndexs.end();

	for ( titer; titer != teiter; ++titer )
	{
		texname = titer->first;
		pRender->m_TerrainTexIndexs[texname] = texCnt;

		++texCnt;
	}

	IoSystem* ioSystem = IoSystem::GetInst();
	string homePath = IoSystem::GetInst()->GetFullPath("home:");
	string selfTexPath = homePath + pTerrain->m_strMapName + ".jpg";

	pTerrain->m_pTerrainTexture->SaveToFile(selfTexPath.c_str(),IFF_JPG);
	//D3DXSaveTextureToFile(selfTexPath.c_str(),D3DXIFF_JPG,pTerrain->m_pTerrainTexture,&pale);
}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:101,代码来源:LocalMapResMgr.cpp


注:本文中的ITexture::Unlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。