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


C++ TexturePtr::GetTexture方法代码示例

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


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

示例1: SetTexture

void Shader::SetTexture(const TexturePtr texture, const std::string &name) {
  auto texture_id = texture->GetTexture();
  auto uniform = GetUniformLocation(name.c_str());
  glUniform1i(uniform, 0);
  glActiveTexture(GL_TEXTURE0 + 0);
  glBindTexture(GL_TEXTURE_2D, texture_id);
}
开发者ID:smasty,项目名称:ppgso,代码行数:7,代码来源:shader.cpp

示例2:

GfxSystem::GfxViewport::GfxViewport( ResourceSystem::ResourcePtr texture ):
	mPosition(Vector2_Zero),
	mSize(Vector2_Zero),
	mTexture(InvalidTextureHandle),
	mRelativeScale(false),
	mGridEnabled(true)
{
	OC_ASSERT(texture->GetType() == ResourceSystem::RESTYPE_TEXTURE);
	TexturePtr textureResource = (TexturePtr)texture; 
	mTexture = textureResource->GetTexture();
	mSize.x = (float32)textureResource->GetWidth();
	mSize.y = (float32)textureResource->GetHeight();
}
开发者ID:Ocerus,项目名称:Ocerus,代码行数:13,代码来源:GfxViewport.cpp

示例3: Open


//.........这里部分代码省略.........
			TexturePtr pTex = ResourceManager::GetInstance().GetResource<Texture>( sphereFileName );
			if( !pTex )
			{
				pTex = TexturePtr(new Texture);
				pTex->CreateFromFile( sphereFileName );

				ResourceManager::GetInstance().AddResource( sphereFileName,pTex );
			}

			pMaterial->textureSphere = pTex;

			tstring ext = PathFindExtension( sphereFileName.c_str() );
			if( ext == _T(".sph" ) )
			{
				pMaterial->spheremap = eSPHEREMAP_MUL;
			}
			else if( ext == _T(".spa") )
			{
				pMaterial->spheremap = eSPHEREMAP_ADD;
			}
		}

		pMaterial->colorToon = D3DXCOLOR( 1.0f,1.0f,1.0f,1.0f );

		tstring toonTexName = _T("");
		tstring toonTexPath = _T("");

		if( 0<=pmdMat->toon_index && pmdMat->toon_index<10 )
		{
			// TODO:デフォルトのtoonファイルは固定パスか・・・
			toonTexName = to_tstring( pmd->toon_list.toon_file_name[pmdMat->toon_index] );
		}

		TexturePtr pTex;
		
		if( !toonTexName.empty() )
		{
			PathAppend( path,toonTexName.c_str() );
			toonTexPath = path;
			PathRemoveFileSpec( path );

			pTex = ResourceManager::GetInstance().GetResource<Texture>( toonTexPath );
			if( !pTex )
			{
				pTex = TexturePtr(new Texture);
				if( !pTex->CreateFromFile( toonTexPath ) )
				{
					pTex.reset();
				}
			}
		}

		if( !pTex )
		{
			pTex = graphics->GetDefaultToonTexture( pmdMat->toon_index );
			if( !pTex )
			{
				toonTexPath = _T("<FFFFFFFF>");

				pTex = ResourceManager::GetInstance().GetResource<Texture>( toonTexPath );
				if( !pTex )
				{
					pTex = TexturePtr(new Texture);
					if( !pTex->CreateDotColor( 0xFFFFFFFF ) )
					{
						pTex.reset();
					}
				}
			}
		}
		
		if( pTex )
		{
			pMaterial->textureToon = pTex;

			ResourceManager::GetInstance().AddResource( toonTexPath,pTex );

			IDirect3DTexture9Ptr pD3DTexture = pTex->GetTexture();

			D3DSURFACE_DESC desc;
			pD3DTexture->GetLevelDesc( 0,&desc );

			D3DLOCKED_RECT lockRect;
			pD3DTexture->LockRect(0, &lockRect, NULL, 0);

			int x = 0;
			int y = desc.Height-1;

			DWORD color;

			memcpy(&color,(BYTE*)lockRect.pBits + lockRect.Pitch*y + 4*x, sizeof(DWORD) );

			pD3DTexture->UnlockRect(0);

			pMaterial->colorToon = D3DXCOLOR( color );
		}
	}

	return PMDModelPtr( new PMDModel(pmd,pmd->material_list.material_count,pMaterials) );
}
开发者ID:ZeusAFK,项目名称:MikuMikuGameEngine,代码行数:101,代码来源:PMDFileLoader.cpp


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