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


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

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


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

示例1:

//------------------------------------------------------------------------------
void sqr::CLoadMapResInfo::MakeTerrainTexture()
{
	CRenderDevice * pRender = NULL;
	pRender = CRenderDevice::GetInst();
	if ( pRender == NULL )
		return;

	CTerrainMesh * pTerrain = CMapEditApp::GetInst()->GetTerrain();

	int texCnt = 0;
	ITexture* pTexture = NULL;

	if ( pTerrain->m_pTerrainTexture == NULL )
		CGraphic::GetInst()->CreateEmptyTexture(EXPAND_MAX_SIZE,EXPAND_MAX_SIZE,1, TF_XRGB32,&(pTerrain->m_pTerrainTexture));

	string texname = "";
	map<string, int16>::iterator iter = m_mapTerrainTextureNames.begin();
	map<string, int16>::iterator eiter = m_mapTerrainTextureNames.end();
	set<string> erroTexList;
	for ( iter; iter != eiter; ++iter )
	{
		texname = iter->first;
		if( texname.empty() )
			continue;

		pTexture = pRender->GetTexture(texname);
		if( texname.find("water.dds") != -1 )
			continue;

		if (NULL==pTexture)
		{
			string log = "拼接过程:"+texname+"纹理无法找到";
			MessageBox(NULL,log.c_str(),"错误",MB_OK);
			erroTexList.insert(texname);
			continue;
		}

		if (NULL==pTexture->GetBuffer())
		{
			string log = "拼接过程:"+texname+"纹理无法找到";
			MessageBox(NULL,log.c_str(),"错误",MB_OK);
			continue;
		}

		UINT H = (texCnt/ROW_SIZE)*EXPAND_TEXTURE_SIZE;
		UINT W = (texCnt%ROW_SIZE)*EXPAND_TEXTURE_SIZE;


		if (pTexture->GetWidth()!=TEXTURE_SIZE||pTexture->GetHeight()!=TEXTURE_SIZE)
		{
			string log = "拼接过程:"+texname+"尺寸不合法,所有贴图纹理应为128X128";
			erroTexList.insert(texname);
			MessageBox(NULL,log.c_str(),"错误",MB_OK);
			continue;
		}

		pRender->m_TerrainTexIndexs[texname] = texCnt;
		//DebugOut("%d, %s\n", texCnt, texname.c_str());
		++texCnt;

		CIRect rectT,rectO;
		_TEXLOCKED_RECT lockT,lockO;
		rectO.top = rectO.left = 0;
		rectO.bottom = rectO.right = TEXTURE_SIZE;
		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)
			{
//.........这里部分代码省略.........
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:101,代码来源:LocalMapResMgr.cpp


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