本文整理汇总了C++中IDirect3DDevice9::DrawIndexedPrimitive方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirect3DDevice9::DrawIndexedPrimitive方法的具体用法?C++ IDirect3DDevice9::DrawIndexedPrimitive怎么用?C++ IDirect3DDevice9::DrawIndexedPrimitive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirect3DDevice9
的用法示例。
在下文中一共展示了IDirect3DDevice9::DrawIndexedPrimitive方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTransform
void NX::Sphere::Render(struct NX::RenderParameter &renderer) {
if (!m_pVertexs) {
return;
}
SetupLightingInfo(renderer);
int nV = (m_iStacks - 1) * (m_iSlices + 1) + 2;
IDirect3DDevice9 *pDevice = renderer.pDXDevice;
m_pEffect->SetMatrix(m_pEffect->GetParameterByName(NULL, "PVMMatrix"), (D3DXMATRIX*)&(renderer.pProjectController->GetWatchMatrix() * GetTransform().GetTransformMatrix()));
m_pEffect->SetTexture(m_pEffect->GetParameterByName(NULL, "BaseColor"),NX::DX9TextureManager::Instance().GetTexture(m_TextureFilePath));
UINT uPasses = 0;
m_pEffect->Begin(&uPasses, 0);
for (int i = 0; i < uPasses; ++i) {
pDevice->SetVertexDeclaration(m_pVertexDesc);
pDevice->SetStreamSource(0, m_pVertexBuffer, 0, sizeof(Vertex));
pDevice->SetIndices(m_pIndexBuffer);
m_pEffect->BeginPass(i);
pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLEFAN, 0, 0, m_iSlices + 2, 0, m_iSlices);
pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLESTRIP, 0, 0, (m_iStacks - 2) * (m_iSlices + 1) * 2, m_iSlices + 2, (m_iStacks - 2) * (m_iSlices + 1) * 2);
pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLEFAN, 0, 0, m_iSlices + 2, (m_iStacks - 2) * (m_iSlices + 1) * 2 + m_iSlices + 2, m_iSlices);
m_pEffect->EndPass();
}
m_pEffect->End();
}
示例2:
Air::U1 System::DrawOpt( const DrawOption& opt )
{
IDirect3DDevice9* pDev = GetGlobal().m_pDevice;
D3DPRIMITIVETYPE drawType = (D3DPRIMITIVETYPE)opt.m_DrawType;
if(opt.m_uiInstanceCount!=0){
SetStreamSourceFreq( 0, D3DSTREAMSOURCE_INDEXEDDATA | opt.m_uiInstanceCount);
SetStreamSourceFreq( 1, D3DSTREAMSOURCE_INSTANCEDATA | 1ul );
}
switch(opt.m_DrawFuncType){
case Draw::FUNC_TYPE_DP:{
pDev->DrawPrimitive(drawType,
opt.m_uiBaseVertexIndex,
opt.m_uiFaceCount);
break;}
case Draw::FUNC_TYPE_DIP:{
pDev->DrawIndexedPrimitive(drawType,
opt.m_uiBaseVertexIndex,
0,
opt.m_uiVertexCount,
opt.m_uiStartIndex,
opt.m_uiFaceCount);
break;}
}
if(opt.m_uiInstanceCount!=0){
SetStreamSourceFreq(0,1);
SetStreamSourceFreq(1,1);
}
return true;
}
示例3: Render
void TexCube::Render()
{
if(NULL == m_pWnd ||
NULL == m_pVB ||
NULL == m_pIB)
{
return;
}
IDirect3DDevice9* pDev = m_pWnd->GetD3DDevice();
pDev->SetStreamSource(0, m_pVB, 0, sizeof(SRNormalTextureVertex));
pDev->SetFVF(SRNormalTextureVertex::FVF);
pDev->SetIndices(m_pIB);
pDev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 24, 0, 12);
}
示例4: sizeof
void f2dGraphics2DImpl::flush(bool Discard)
{
if(m_Commands.empty())
{
if(Discard)
{
// 解锁缓冲区
m_pVB->Unlock();
m_pIB->Unlock();
m_pVB->Lock(0, m_VBMaxCount * sizeof(f2dGraphics2DVertex), (void**)&m_pVBData, D3DLOCK_DISCARD);
m_pIB->Lock(0, m_IBMaxCount * sizeof(fuShort), (void**)&m_pIBData, D3DLOCK_DISCARD);
m_VBUsedCount = 0;
m_IBUsedCount = 0;
m_VBAlloced = 0;
m_IBAlloced = 0;
}
else
return;
}
// 解锁缓冲区
m_pVB->Unlock();
m_pIB->Unlock();
// 绘制并统计有效顶点个数
IDirect3DDevice9* pDev = (IDirect3DDevice9*)m_pParent->GetHandle();
vector<RenderCommand>::iterator i = m_Commands.begin();
while(i != m_Commands.end())
{
if(i->pTex)
{
pDev->SetTexture(0, (IDirect3DBaseTexture9*)i->pTex->GetHandle());
i->pTex->Release();
}
else
pDev->SetTexture(0, NULL);
pDev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, m_VBUsedCount, 0, i->VertCount, m_IBUsedCount, i->IndexCount/3);
m_VBUsedCount += i->VertCount;
m_IBUsedCount += i->IndexCount;
++i;
}
m_Commands.clear();
// 重新锁定缓冲区
if(m_VBUsedCount == m_VBMaxCount || m_IBUsedCount == m_IBMaxCount)
Discard = true;
if(Discard)
{
m_pVB->Lock(0, m_VBMaxCount * sizeof(f2dGraphics2DVertex), (void**)&m_pVBData, D3DLOCK_DISCARD);
m_pIB->Lock(0, m_IBMaxCount * sizeof(fuShort), (void**)&m_pIBData, D3DLOCK_DISCARD);
m_VBUsedCount = 0;
m_IBUsedCount = 0;
m_VBAlloced = 0;
m_IBAlloced = 0;
}
else
{
m_pVB->Lock(m_VBUsedCount * sizeof(f2dGraphics2DVertex), (m_VBMaxCount - m_VBUsedCount) * sizeof(f2dGraphics2DVertex), (void**)&m_pVBData, D3DLOCK_NOOVERWRITE);
m_pIB->Lock(m_IBUsedCount * sizeof(fuShort), (m_IBMaxCount - m_IBUsedCount) * sizeof(fuShort), (void**)&m_pIBData, D3DLOCK_NOOVERWRITE);
m_VBAlloced = 0;
m_IBAlloced = 0;
}
}