本文整理汇总了C++中std::unique_ptr::Begin方法的典型用法代码示例。如果您正苦于以下问题:C++ unique_ptr::Begin方法的具体用法?C++ unique_ptr::Begin怎么用?C++ unique_ptr::Begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::unique_ptr
的用法示例。
在下文中一共展示了unique_ptr::Begin方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawCenterGrid
void DrawCenterGrid(FXMVECTOR yAxis1, FXMVECTOR yAxis2)
{
VertexPositionColor v1(yAxis1, Colors::Red);
VertexPositionColor v2(yAxis2, Colors::Red);
DXUTGetD3D11DeviceContext()->IASetInputLayout(g_pBatchInputLayout);
g_BatchEffect->Apply(DXUTGetD3D11DeviceContext());
g_Batch->Begin();
g_Batch->DrawLine( v1, v2 );
g_Batch->End();
}
示例2: DrawFrustum
//--------------------------------------------------------------------------------------
void DrawFrustum( const BoundingFrustum& frustum, FXMVECTOR color )
{
XMFLOAT3 corners[ BoundingFrustum::CORNER_COUNT ];
frustum.GetCorners( corners );
VertexPositionColor verts[24];
verts[0].position = corners[0];
verts[1].position = corners[1];
verts[2].position = corners[1];
verts[3].position = corners[2];
verts[4].position = corners[2];
verts[5].position = corners[3];
verts[6].position = corners[3];
verts[7].position = corners[0];
verts[8].position = corners[0];
verts[9].position = corners[4];
verts[10].position = corners[1];
verts[11].position = corners[5];
verts[12].position = corners[2];
verts[13].position = corners[6];
verts[14].position = corners[3];
verts[15].position = corners[7];
verts[16].position = corners[4];
verts[17].position = corners[5];
verts[18].position = corners[5];
verts[19].position = corners[6];
verts[20].position = corners[6];
verts[21].position = corners[7];
verts[22].position = corners[7];
verts[23].position = corners[4];
for( size_t j = 0; j < _countof(verts); ++j )
{
XMStoreFloat4( &verts[j].color, color );
}
auto context = DXUTGetD3D11DeviceContext();
g_BatchEffect->Apply( context );
context->IASetInputLayout( g_pBatchInputLayout );
g_Batch->Begin();
g_Batch->Draw( D3D11_PRIMITIVE_TOPOLOGY_LINELIST, verts, _countof( verts ) );
g_Batch->End();
}
示例3: DrawCube
//--------------------------------------------------------------------------------------
void DrawCube( CXMMATRIX mWorld, FXMVECTOR color )
{
static const XMVECTOR s_verts[8] =
{
{ -1, -1, -1, 0 },
{ 1, -1, -1, 0 },
{ 1, -1, 1, 0 },
{ -1, -1, 1, 0 },
{ -1, 1, -1, 0 },
{ 1, 1, -1, 0 },
{ 1, 1, 1, 0 },
{ -1, 1, 1, 0 }
};
static const WORD s_indices[] =
{
0, 1,
1, 2,
2, 3,
3, 0,
4, 5,
5, 6,
6, 7,
7, 4,
0, 4,
1, 5,
2, 6,
3, 7
};
VertexPositionColor verts[8];
for( int i=0; i < 8; ++i )
{
XMVECTOR v = XMVector3Transform( s_verts[i], mWorld );
XMStoreFloat3( &verts[i].position, v );
XMStoreFloat4( &verts[i].color, color );
}
auto context = DXUTGetD3D11DeviceContext();
g_BatchEffect->Apply( context );
context->IASetInputLayout( g_pBatchInputLayout );
g_Batch->Begin();
g_Batch->DrawIndexed( D3D11_PRIMITIVE_TOPOLOGY_LINELIST, s_indices, _countof( s_indices ), verts, 8 );
g_Batch->End();
}
示例4: DrawRing
//--------------------------------------------------------------------------------------
void DrawRing( FXMVECTOR Origin, FXMVECTOR MajorAxis, FXMVECTOR MinorAxis, CXMVECTOR color )
{
static const DWORD dwRingSegments = 32;
VertexPositionColor verts[ dwRingSegments + 1 ];
FLOAT fAngleDelta = XM_2PI / ( float )dwRingSegments;
// Instead of calling cos/sin for each segment we calculate
// the sign of the angle delta and then incrementally calculate sin
// and cosine from then on.
XMVECTOR cosDelta = XMVectorReplicate( cosf( fAngleDelta ) );
XMVECTOR sinDelta = XMVectorReplicate( sinf( fAngleDelta ) );
XMVECTOR incrementalSin = XMVectorZero();
static const XMVECTOR initialCos =
{
1.0f, 1.0f, 1.0f, 1.0f
};
XMVECTOR incrementalCos = initialCos;
for( DWORD i = 0; i < dwRingSegments; i++ )
{
XMVECTOR Pos;
Pos = XMVectorMultiplyAdd( MajorAxis, incrementalCos, Origin );
Pos = XMVectorMultiplyAdd( MinorAxis, incrementalSin, Pos );
XMStoreFloat3( &verts[i].position, Pos );
XMStoreFloat4( &verts[i].color, color );
// Standard formula to rotate a vector.
XMVECTOR newCos = incrementalCos * cosDelta - incrementalSin * sinDelta;
XMVECTOR newSin = incrementalCos * sinDelta + incrementalSin * cosDelta;
incrementalCos = newCos;
incrementalSin = newSin;
}
verts[ dwRingSegments ] = verts[0];
// Draw ring
auto context = DXUTGetD3D11DeviceContext();
g_BatchEffect->Apply( context );
context->IASetInputLayout( g_pBatchInputLayout );
g_Batch->Begin();
g_Batch->Draw( D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP, verts, dwRingSegments+1 );
g_Batch->End();
}
示例5: DrawGrid
void DrawGrid( FXMVECTOR xAxis, FXMVECTOR yAxis, FXMVECTOR origin, size_t xdivs, size_t ydivs, GXMVECTOR color )
{
auto context = DXUTGetD3D11DeviceContext();
g_BatchEffect->Apply( context );
context->IASetInputLayout( g_pBatchInputLayout );
g_Batch->Begin();
xdivs = std::max<size_t>( 1, xdivs );
ydivs = std::max<size_t>( 1, ydivs );
for( size_t i = 0; i <= xdivs; ++i )
{
float fPercent = float(i) / float(xdivs);
fPercent = ( fPercent * 2.0f ) - 1.0f;
XMVECTOR vScale = XMVectorScale( xAxis, fPercent );
vScale = XMVectorAdd( vScale, origin );
VertexPositionColor v1( XMVectorSubtract( vScale, yAxis ), color );
VertexPositionColor v2( XMVectorAdd( vScale, yAxis ), color );
g_Batch->DrawLine( v1, v2 );
}
for( size_t i = 0; i <= ydivs; i++ )
{
FLOAT fPercent = float(i) / float(ydivs);
fPercent = ( fPercent * 2.0f ) - 1.0f;
XMVECTOR vScale = XMVectorScale( yAxis, fPercent );
vScale = XMVectorAdd( vScale, origin );
VertexPositionColor v1( XMVectorSubtract( vScale, xAxis ), color );
VertexPositionColor v2( XMVectorAdd( vScale, xAxis ), color );
g_Batch->DrawLine( v1, v2 );
}
g_Batch->End();
}
示例6: DrawRay
//--------------------------------------------------------------------------------------
void DrawRay( FXMVECTOR Origin, FXMVECTOR Direction, bool bNormalize, FXMVECTOR color )
{
VertexPositionColor verts[3];
XMStoreFloat3( &verts[0].position, Origin );
XMVECTOR NormDirection = XMVector3Normalize( Direction );
XMVECTOR RayDirection = ( bNormalize ) ? NormDirection : Direction;
XMVECTOR PerpVector = XMVector3Cross( NormDirection, g_XMIdentityR1 );
if( XMVector3Equal( XMVector3LengthSq( PerpVector ), g_XMZero ) )
{
PerpVector = XMVector3Cross( NormDirection, g_XMIdentityR2 );
}
PerpVector = XMVector3Normalize( PerpVector );
XMStoreFloat3( &verts[1].position, XMVectorAdd( RayDirection, Origin ) );
PerpVector = XMVectorScale( PerpVector, 0.0625f );
NormDirection = XMVectorScale( NormDirection, -0.25f );
RayDirection = XMVectorAdd( PerpVector, RayDirection );
RayDirection = XMVectorAdd( NormDirection, RayDirection );
XMStoreFloat3( &verts[2].position, XMVectorAdd( RayDirection, Origin ) );
XMStoreFloat4( &verts[0].color, color );
XMStoreFloat4( &verts[1].color, color );
XMStoreFloat4( &verts[2].color, color );
auto context = DXUTGetD3D11DeviceContext();
g_BatchEffect->Apply( context );
context->IASetInputLayout( g_pBatchInputLayout );
g_Batch->Begin();
g_Batch->Draw( D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP, verts, 2 );
g_Batch->End();
}
示例7: DrawTriangle
//--------------------------------------------------------------------------------------
void DrawTriangle( FXMVECTOR PointA, FXMVECTOR PointB, FXMVECTOR PointC, CXMVECTOR color )
{
VertexPositionColor verts[4];
XMStoreFloat3( &verts[0].position, PointA );
XMStoreFloat3( &verts[1].position, PointB );
XMStoreFloat3( &verts[2].position, PointC );
XMStoreFloat3( &verts[3].position, PointA );
XMStoreFloat4( &verts[0].color, color );
XMStoreFloat4( &verts[1].color, color );
XMStoreFloat4( &verts[2].color, color );
XMStoreFloat4( &verts[3].color, color );
auto context = DXUTGetD3D11DeviceContext();
g_BatchEffect->Apply( context );
context->IASetInputLayout( g_pBatchInputLayout );
g_Batch->Begin();
g_Batch->Draw( D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP, verts, 4 );
g_Batch->End();
}
示例8: Run
virtual void Run()
{
Given("an output stream and output", [&]()
{
m_actualOutput.str("");
m_output = std::unique_ptr<ut11::out::StdOutput>(new ut11::out::StdOutput(m_actualOutput));
});
When("begin and end without running any tests", [&]()
{
m_output->Begin();
m_output->Finish(10, 7);
});
Then("the output is as expected", [&]()
{
AssertThat(m_actualOutput.str(), ut11::Is::EqualTo("\nFinished!\nRan: 10\nSucceeded: 7\n"));
});
When("running a test fixture with just a Then", [&]()
{
m_output->Begin();
m_output->BeginFixture("fixture");
m_output->BeginTest();
m_output->BeginThen("then");
m_output->EndThen("then");
m_output->EndTest();
m_output->EndFixture("fixture");
m_output->Finish(1, 1);
});
Then("the output is as expected", [&]()
{
auto stringVal = m_actualOutput.str();
auto startOfTime = stringVal.find('[');
auto endOfTime = stringVal.find(']');
stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);
AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\t\t\tThen: then \n\nFinished!\nRan: 1\nSucceeded: 1\n"));
});
When("running two test fixtures with just a Then", [&]()
{
m_output->Begin();
m_output->BeginFixture("fixture");
m_output->BeginTest();
m_output->BeginThen("then");
m_output->EndThen("then");
m_output->EndTest();
m_output->EndFixture("fixture");
m_output->BeginFixture("fixture2");
m_output->BeginTest();
m_output->BeginThen("then2");
m_output->EndThen("then2");
m_output->EndTest();
m_output->EndFixture("fixture2");
m_output->Finish(2, 2);
});
Then("the output is as expected", [&]()
{
auto stringVal = m_actualOutput.str();
auto startOfTime = stringVal.find('[');
auto endOfTime = stringVal.find(']');
stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);
startOfTime = stringVal.find('[');
endOfTime = stringVal.find(']');
stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);
AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\t\t\tThen: then \nFixture: fixture2\n\t\t\tThen: then2 \n\nFinished!\nRan: 2\nSucceeded: 2\n"));
});
When("running a test fixture with just a When and Then", [&]()
{
m_output->Begin();
m_output->BeginFixture("fixture");
m_output->BeginTest();
m_output->BeginWhen("when");
m_output->EndWhen("then");
m_output->BeginThen("then");
m_output->EndThen("then");
m_output->EndTest();
m_output->EndFixture("fixture");
m_output->Finish(1, 1);
});
Then("the output is as expected", [&]()
{
auto stringVal = m_actualOutput.str();
auto startOfTime = stringVal.find('[');
auto endOfTime = stringVal.find(']');
stringVal = stringVal.erase(startOfTime, endOfTime - startOfTime + 1);
AssertThat(stringVal, ut11::Is::EqualTo("Fixture: fixture\n\t\tWhen: when\n\t\t\tThen: then \n\nFinished!\nRan: 1\nSucceeded: 1\n"));
});
When("running a test fixture with a Given When and Then", [&]()
{
m_output->Begin();
m_output->BeginFixture("fixture");
m_output->BeginTest();
m_output->BeginGiven("given");
m_output->EndGiven("given");
m_output->BeginWhen("when");
//.........这里部分代码省略.........
示例9: Render
//--------------------------------------------------------------------------------------
// Render a frame
//--------------------------------------------------------------------------------------
void Render()
{
// Update our time
static float t = 0.0f;
static float dt = 0.f;
if( g_driverType == D3D_DRIVER_TYPE_REFERENCE )
{
t += ( float )XM_PI * 0.0125f;
}
else
{
static uint64_t dwTimeStart = 0;
static uint64_t dwTimeLast = 0;
uint64_t dwTimeCur = GetTickCount64();
if( dwTimeStart == 0 )
dwTimeStart = dwTimeCur;
t = ( dwTimeCur - dwTimeStart ) / 1000.0f;
dt = ( dwTimeCur - dwTimeLast ) / 1000.0f;
dwTimeLast = dwTimeCur;
}
// Rotate cube around the origin
g_World = XMMatrixRotationY( t );
#ifdef DXTK_AUDIO
g_audioTimerAcc -= dt;
if ( g_audioTimerAcc < 0 )
{
g_audioTimerAcc = 4.f;
g_waveBank->Play( g_audioEvent++ );
if ( g_audioEvent >= 11 )
g_audioEvent = 0;
}
if ( !g_audEngine->Update() )
{
// Error cases are handled by the message loop
}
#endif // DXTK_AUDIO
//
// Clear the back buffer
//
g_pImmediateContext->ClearRenderTargetView( g_pRenderTargetView, Colors::MidnightBlue );
//
// Clear the depth buffer to 1.0 (max depth)
//
g_pImmediateContext->ClearDepthStencilView( g_pDepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0 );
// Draw procedurally generated dynamic grid
const XMVECTORF32 xaxis = { 20.f, 0.f, 0.f };
const XMVECTORF32 yaxis = { 0.f, 0.f, 20.f };
DrawGrid( *g_Batch, xaxis, yaxis, g_XMZero, 20, 20, Colors::Gray );
// Draw sprite
g_Sprites->Begin( SpriteSortMode_Deferred );
g_Sprites->Draw( g_pTextureRV2, XMFLOAT2(10, 75 ), nullptr, Colors::White );
g_Font->DrawString( g_Sprites.get(), L"DirectXTK Simple Sample", XMFLOAT2( 100, 10 ), Colors::Yellow );
g_Sprites->End();
// Draw 3D object
XMMATRIX local = XMMatrixMultiply( g_World, XMMatrixTranslation( -2.f, -2.f, 4.f ) );
g_Shape->Draw( local, g_View, g_Projection, Colors::White, g_pTextureRV1 );
XMVECTOR qid = XMQuaternionIdentity();
const XMVECTORF32 scale = { 0.01f, 0.01f, 0.01f};
const XMVECTORF32 translate = { 3.f, -2.f, 4.f };
XMVECTOR rotate = XMQuaternionRotationRollPitchYaw( 0, XM_PI/2.f, XM_PI/2.f );
local = XMMatrixMultiply( g_World, XMMatrixTransformation( g_XMZero, qid, scale, g_XMZero, rotate, translate ) );
g_Model->Draw( g_pImmediateContext, *g_States, local, g_View, g_Projection );
//
// Present our back buffer to our front buffer
//
g_pSwapChain->Present( 0, 0 );
}