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


C++ CGrowableArray::Reset方法代码示例

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


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

示例1: sizeof

void Dx11TextHelper::EndText11( ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3d11DeviceContext )
{

	// ensure our buffer size can hold our sprites
	UINT FontDataBytes = g_FontVertices.GetSize() * sizeof( DXUTSpriteVertex );
	if( g_FontBufferBytes11 < FontDataBytes )
	{
		SAFE_RELEASE( g_pFontBuffer11 );
		g_FontBufferBytes11 = FontDataBytes;

		D3D11_BUFFER_DESC BufferDesc;
		BufferDesc.ByteWidth = g_FontBufferBytes11;
		BufferDesc.Usage = D3D11_USAGE_DYNAMIC;
		BufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
		BufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
		BufferDesc.MiscFlags = 0;

		pd3dDevice->CreateBuffer( &BufferDesc, NULL, &g_pFontBuffer11 );
		//DXUT_SetDebugName( g_pFontBuffer11, "DXUT Text11" );
	}

	// Copy the sprites over
	D3D11_BOX destRegion;
	destRegion.left = 0;
	destRegion.right = FontDataBytes;
	destRegion.top = 0;
	destRegion.bottom = 1;
	destRegion.front = 0;
	destRegion.back = 1;
	D3D11_MAPPED_SUBRESOURCE MappedResource;
	if ( S_OK == pd3d11DeviceContext->Map( g_pFontBuffer11, 0, D3D11_MAP_WRITE_DISCARD, 0, &MappedResource ) ) { 
		CopyMemory( MappedResource.pData, (void*)g_FontVertices.GetData(), FontDataBytes );
		pd3d11DeviceContext->Unmap(g_pFontBuffer11, 0);
	}

	

	ID3D11ShaderResourceView* pOldTexture = NULL;
	pd3d11DeviceContext->PSGetShaderResources( 0, 1, &pOldTexture );
	//pd3d11DeviceContext->PSSetShaderResources( 0, 1, &g_pFont11 );

	

	// Draw
	UINT Stride = sizeof( DXUTSpriteVertex );
	UINT Offset = 0;
	pd3d11DeviceContext->IASetVertexBuffers( 0, 1, &g_pFontBuffer11, &Stride, &Offset );
	pd3d11DeviceContext->IASetIndexBuffer( NULL, DXGI_FORMAT_R16_UINT, 0 );
	pd3d11DeviceContext->IASetInputLayout( g_pInputLayout11 );
	pd3d11DeviceContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );

	m_pFontTex->SetResource(g_pFont11);

	D3DX11_TECHNIQUE_DESC techDesc;
	g_pFontTec->GetDesc( &techDesc );

	for( UINT p = 0; p < techDesc.Passes; ++p )
	{
		g_pFontTec->GetPassByIndex( p )->Apply( 0, pd3d11DeviceContext );

		pd3d11DeviceContext->Draw( g_FontVertices.GetSize(), 0 );
	}

	pd3d11DeviceContext->PSSetShaderResources( 0, 1, &pOldTexture );
	SAFE_RELEASE( pOldTexture );

	g_FontVertices.Reset();
}
开发者ID:DanielNeander,项目名称:my-3d-engine,代码行数:68,代码来源:Dx11TextHelper.cpp


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