本文整理汇总了C++中LPDIRECT3DDEVICE9::DrawIndexedPrimitive方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3DDEVICE9::DrawIndexedPrimitive方法的具体用法?C++ LPDIRECT3DDEVICE9::DrawIndexedPrimitive怎么用?C++ LPDIRECT3DDEVICE9::DrawIndexedPrimitive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3DDEVICE9
的用法示例。
在下文中一共展示了LPDIRECT3DDEVICE9::DrawIndexedPrimitive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Direct3DUpdate
void Direct3DUpdate(HWND hwnd)
{
//////////////////////////////////////////////////////////////////////////
// Five steps of rendering: clear, beginScene, render, EndScene, present
//////////////////////////////////////////////////////////////////////////
gPD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
RECT formatRect;
GetClientRect(hwnd, &formatRect);
gPD3DDevice->BeginScene();
gPD3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
gPD3DDevice->SetStreamSource(0, gPVertexBuffer, 0, sizeof(CUSTOM_VERTEX));
gPD3DDevice->SetFVF(D3DFVF_CUSTOM_VERTEX);
gPD3DDevice->SetIndices(gPIndexBuffer);
gPD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 17, 0, 16);
int charCount = swprintf_s(gStrFPS, 20, _T("FPS:%0.3f"), GetFPS());
gPFont->DrawText(NULL, gStrFPS, charCount, &formatRect, DT_TOP | DT_RIGHT, D3DCOLOR_XRGB(255, 39, 136));
gPD3DDevice->EndScene();
gPD3DDevice->Present(nullptr, nullptr, nullptr, nullptr);
}
示例2: Render
// Render the model using the given matrix list as a hierarchy (must be one matrix per node)
// and from the given camera
void CMesh::Render( CMatrix4x4* matrices, CCamera* camera )
{
if (m_HasGeometry)
{
for (TUInt32 subMesh = 0; subMesh < m_NumSubMeshes; ++subMesh)
{
// Get a reference to the submesh and its material to reduce code clutter
SSubMeshDX& sub = m_SubMeshesDX[subMesh];
SMeshMaterialDX& material = m_Materials[sub.material];
// Set textures from the material
for (TUInt32 texture = 0; texture < material.numTextures; ++texture)
{
g_pd3dDevice->SetTexture( texture, material.textures[texture] );
}
// Set material properties
SetMaterialColour( material.diffuseColour, material.specularColour, material.specularPower );
// Use the render method from the sub-mesh's material and the matrix from its node
UseMethod( material.renderMethod, &matrices[sub.node], camera );
// Tell DirectX the vertex and index buffers to use
g_pd3dDevice->SetStreamSource( 0, sub.vertexBuffer, 0, sub.vertexSize );
g_pd3dDevice->SetIndices( sub.indexBuffer );
// Draw the primitives from the buffer - a triangle list
g_pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, sub.numVertices, 0,
sub.numIndices / 3 );
}
}
}
示例3: SUCCEEDED
//-------------------------------------------------------------
// Trigger the render of indexed primitives
//-------------------------------------------------------------
void VCND3D9Shader::RenderIndexedPrimitive( VCNUInt faceCount, VCNUInt vertexCount, VCNInt primitiveType /*= D3DPT_TRIANGLELIST*/ )
{
HRESULT hr = S_FALSE;
// Get a pointer to the D3D device
LPDIRECT3DDEVICE9 device = GetD3DDevice();
// Start the technique and commit all the data
VCNUInt numPasses;
hr = mShader->Begin( &numPasses, 0 );
VCN_ASSERT( SUCCEEDED(hr) );
// Render all the passes of this technique (generally only 1).
for( VCNUInt i=0; i<numPasses; ++i )
{
// Start the pass
hr = mShader->BeginPass( i );
VCN_ASSERT( SUCCEEDED(hr) );
// Render indexed primitives
hr = device->DrawIndexedPrimitive( (D3DPRIMITIVETYPE)primitiveType, 0, 0, vertexCount, 0, faceCount );
VCN_ASSERT( hr != D3DERR_INVALIDCALL && "VCNDXShader::RenderIndexedPrimitive - D3DERR_INVALIDCALL!" );
VCN_ASSERT( SUCCEEDED(hr) && "VCNDXShader::RenderIndexedPrimitive - DRAW FAILED!" );
// End the pass
hr = mShader->EndPass();
VCN_ASSERT( SUCCEEDED(hr) );
}
hr = mShader->End();
VCN_ASSERT( SUCCEEDED(hr) );
}
示例4: render_submodel
void render_submodel( LPDIRECT3DDEVICE9 device, SubModel& submodel )
{
if( submodel.texture ) {
device->SetTextureStageState(
0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
device->SetTextureStageState(
0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
device->SetTextureStageState(
0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
device->SetTextureStageState(
0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
device->SetTextureStageState(
1, D3DTSS_COLOROP, D3DTOP_DISABLE );
device->SetTextureStageState(
1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
device->SetTexture( 0, submodel.texture->texture );
} else {
device->SetTextureStageState(
0, D3DTSS_COLOROP, D3DTOP_DISABLE );
device->SetTextureStageState(
0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
device->SetTexture( 0, NULL );
}
device->SetIndices( submodel.ib );
device->SetStreamSource(
0, submodel.vb, 0, sizeof(model_vertex_type) );
device->SetFVF( model_vertex_type::format );
device->DrawIndexedPrimitive(
D3DPT_TRIANGLELIST, 0, 0, submodel.index_source.size(), 0,
submodel.index_source.size() / 3 );
}
示例5: DrawMesh
/**-----------------------------------------------------------------------------
* 메시 그리기
*------------------------------------------------------------------------------
*/
void DrawMesh( D3DXMATRIXA16* pMat )
{
g_pd3dDevice->SetTransform( D3DTS_WORLD, pMat );
g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) );
g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
g_pd3dDevice->SetIndices( g_pIB );
g_pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, g_cxHeight*g_czHeight, 0, (g_cxHeight-1)*(g_czHeight-1)*2 );
}
示例6: DrawShadowVolume
//*************************************************************************************************************
void DrawShadowVolume(const ShadowCaster& caster)
{
extrude->SetMatrix("matWorld", &caster.world);
extrude->CommitChanges();
device->SetVertexDeclaration(shadowdecl);
device->SetStreamSource(0, caster.vertices, 0, sizeof(D3DXVECTOR4));
device->SetIndices(caster.indices);
device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, caster.numvertices, 0, caster.numfaces);
}
示例7: DrawCube
void DrawCube()
{
// translate model to origin
D3DXMATRIX world ;
D3DXMatrixTranslation(&world, 0.0f, 0.0f, 0.0f) ;
g_pd3dDevice->SetTransform(D3DTS_WORLD, &world) ;
// set view
D3DXVECTOR3 eyePt(5.0f, 5.0f, -5.0f) ;
D3DXVECTOR3 upVec(0.0f, 1.0f, 0.0f) ;
D3DXVECTOR3 lookCenter(0.0f, 0.0f, 0.0f) ;
D3DXMATRIX view ;
D3DXMatrixLookAtLH(&view, &eyePt, &lookCenter, &upVec) ;
g_pd3dDevice->SetTransform(D3DTS_VIEW, &view) ;
// set projection
D3DXMATRIX proj ;
D3DXMatrixPerspectiveFovLH(&proj, D3DX_PI / 4, 1.0f, 1.0f, 1000.0f) ;
g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &proj) ;
D3DXMATRIX worldviewproj = world * view * proj;
// Set matrix
g_pEffect->SetMatrix(g_hWVP, &worldviewproj);
// Set technique
g_pEffect->SetTechnique(g_hTech);
// Render pass
UINT numPass = 0;
g_pEffect->Begin(&numPass, 0);
g_pEffect->BeginPass(0);
// Set texture
D3DXCreateTextureFromFile(g_pd3dDevice, "../Common/Media/crate.jpg", &g_pCubeTexture) ;
g_pEffect->SetTexture("g_pCubeTexture", g_pCubeTexture);
/*g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);*/
// Set stream source, and index buffer
g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(Vertex) );
g_pd3dDevice->SetIndices(g_pIB) ;
g_pd3dDevice->SetFVF(VERTEX_FVF) ;
// Totally 24 points and 12 triangles
g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 24, 0, 12) ;
g_pEffect->EndPass();
g_pEffect->End();
}
示例8:
HRESULT HookIDirect3DDevice9::DrawIndexedPrimitive(LPVOID _this,
D3DPRIMITIVETYPE PrimitiveType,
INT BaseVertexIndex,
UINT MinVertexIndex,
UINT NumVertices,
UINT startIndex,
UINT primCount)
{
LOG_API();
return pD3Dev->DrawIndexedPrimitive(PrimitiveType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
}
示例9: Draw
void cSubDivSurf::Draw( matrix4& mat )
{
LPDIRECT3DDEVICE9 lpDevice = Graphics()->GetDevice();
Graphics()->SetWorldMatrix( mat );
HRESULT hr;
// The index buffer
LPDIRECT3DINDEXBUFFER9 pIndexBuffer = 0;
// Create the index buffer
lpDevice->CreateIndexBuffer(
m_nTris * 3 * sizeof( WORD ), // Size in bytes of buffer
D3DUSAGE_WRITEONLY, // Will only be writing to the buffer
D3DFMT_INDEX16, // 16 bit indices
D3DPOOL_DEFAULT, // Default memory pooling
&pIndexBuffer, // Address of the buffer pointer
NULL ); // Reserved. set to NULL
// Pointer to the index buffer data
WORD* pData = 0;
// Lock the index buffer
pIndexBuffer->Lock( 0, 0, (void**)&pData, 0 );
// Copy the index data into the index buffer
CopyMemory( pData, m_d3dTriList, m_nTris * 3 * sizeof( WORD ) );
// Unlock the index buffer
pIndexBuffer->Unlock();
// Tell Direct3D to use the index buffer
lpDevice->SetIndices( pIndexBuffer );
// Attach the vertex buffer to rendering stream 0
lpDevice->SetStreamSource( 0, m_pVertexBuffer, 0, sizeof( sVertex ) );
// Draw the primitive
hr = lpDevice->DrawIndexedPrimitive(
D3DPT_TRIANGLELIST,
0,
0,
m_nVerts,
0,
m_nTris );
if( FAILED( hr ) )
{
DP0("[cSubDivSurf::Draw]: DrawIndexedPrimitive failed!\n");
}
pIndexBuffer->Release();
}
示例10: Render
//랜더
void Render(int timeDelta)
{
//화면 청소
if (SUCCEEDED(g_pDevice->Clear(
0, //청소할 영역의 D3DRECT 배열 갯수 ( 전체 클리어 0 )
NULL, //청소할 영역의 D3DRECT 배열 포인터 ( 전체 클리어 NULL )
D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, //청소될 버퍼 플레그 ( D3DCLEAR_TARGET 컬러버퍼, D3DCLEAR_ZBUFFER 깊이버퍼, D3DCLEAR_STENCIL 스텐실버퍼
D3DCOLOR_XRGB(255, 255, 255), //컬러버퍼를 청소하고 채워질 색상( 0xAARRGGBB )
1.0f, //깊이버퍼를 청소할값 ( 0 ~ 1 0 이 카메라에서 제일가까운 1 이 카메라에서 제일 먼 )
0 //스텐실 버퍼를 채울값
)))
{
//화면 청소가 성공적으로 이루어 졌다면... 랜더링 시작
g_pDevice->BeginScene();
Matrix44 mR;
if (g_ani)
{
g_alpha += timeDelta / 1000.f;
if (g_alpha > 1)
{
g_alpha = 1;
g_ani = false;
}
}
Vector3 v = g_from.Interpolate(g_to, g_alpha);
Quaternion quat(Vector3(0,1,0), v);
mR = quat.GetMatrix();
Matrix44 tm = mR * g_LocalTm;
g_pDevice->SetTransform(D3DTS_WORLD, (D3DXMATRIX*)&tm);
g_pDevice->SetTexture(0, g_Texture);
g_pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
g_pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
g_pDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
g_pDevice->SetMaterial(&g_Mtrl);
g_pDevice->SetStreamSource( 0, g_pVB, 0, sizeof(Vertex) );
g_pDevice->SetIndices(g_pIB);
g_pDevice->SetFVF( Vertex::FVF );
g_pDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, g_VtxSize, 0, g_FaceSize);
//랜더링 끝
g_pDevice->EndScene();
//랜더링이 끝났으면 랜더링된 내용 화면으로 전송
g_pDevice->Present( NULL, NULL, NULL, NULL );
}
}
示例11: render
VOID render(){
g_pDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(192,192,192), 1.0f, 0);
if(SUCCEEDED(g_pDevice->BeginScene())){
//Render to the back-buffer
g_pDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX));
g_pDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
g_pDevice->SetIndices(g_pIB);
g_pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0,0,9,0,8);
g_pDevice->EndScene();
}
g_pDevice->Present(NULL, NULL, NULL, NULL);
}
示例12: Render
//-------------------------------------------------
// Name: Render
// Desc:
//-------------------------------------------------
HRESULT cprimitive::Render(LPDIRECT3DDEVICE9 pd3dDevice)
{
HRESULT hr;
W( pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ) );
W( pd3dDevice->SetIndices(g_pIB) );
W( pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) ) );
W( pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ) );
W( pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, m_numVertices, 0, m_numIndices/3) );
return S_OK;
}
示例13: Render
void ModelMesh::Render( LPDIRECT3DDEVICE9 device )
{
if( !IsLoaded() )
return;
device->SetRenderState( D3DRS_FILLMODE, m_d3d_fillmode);
device->SetRenderState( D3DRS_CULLMODE, m_d3d_cullmode );
device->SetStreamSource( 0, m_vb, 0, sizeof(ModelVertexStruct) );
device->SetFVF( ModelVertexStruct::FVF );
device->SetIndices( m_ib );
device->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, m_vertex_size, 0, m_index_size / 3 );
}
示例14: Render
//랜더
void Render(int timeDelta)
{
//화면 청소
if (SUCCEEDED(g_pDevice->Clear(
0, //청소할 영역의 D3DRECT 배열 갯수 ( 전체 클리어 0 )
NULL, //청소할 영역의 D3DRECT 배열 포인터 ( 전체 클리어 NULL )
D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, //청소될 버퍼 플레그 ( D3DCLEAR_TARGET 컬러버퍼, D3DCLEAR_ZBUFFER 깊이버퍼, D3DCLEAR_STENCIL 스텐실버퍼
D3DCOLOR_XRGB(150, 150, 150), //컬러버퍼를 청소하고 채워질 색상( 0xAARRGGBB )
1.0f, //깊이버퍼를 청소할값 ( 0 ~ 1 0 이 카메라에서 제일가까운 1 이 카메라에서 제일 먼 )
0 //스텐실 버퍼를 채울값
)))
{
//화면 청소가 성공적으로 이루어 졌다면... 랜더링 시작
g_pDevice->BeginScene();
g_pDevice->SetTransform(D3DTS_WORLD, (D3DXMATRIX*)&global->localTm);
g_pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
g_pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
g_pDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
g_pDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, global->addressMode) ;
g_pDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, global->addressMode) ;
g_pDevice->SetMaterial(&global->mtrl);
g_pDevice->SetTexture(0, global->texture);
g_pDevice->SetStreamSource( 0, global->vb, 0, sizeof(Vertex) );
g_pDevice->SetIndices(global->ib);
g_pDevice->SetFVF( Vertex::FVF );
g_pDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, global->vtxSize, 0, global->faceSize);
switch (global->mode)
{
case sGlobal::RENDER_FACE_NORMAL:
g_pDevice->SetStreamSource( 0, global->fnvb, 0, sizeof(Vertex) );
g_pDevice->DrawPrimitive( D3DPT_LINELIST, 0, global->faceNormalVtxSize/2);
break;
case sGlobal::RENDER_VERTEX_NORMAL:
g_pDevice->SetStreamSource( 0, global->vnvb, 0, sizeof(Vertex) );
g_pDevice->DrawPrimitive( D3DPT_LINELIST, 0, global->vertexNormalVtxSize/2);
break;
}
//랜더링 끝
g_pDevice->EndScene();
//랜더링이 끝났으면 랜더링된 내용 화면으로 전송
g_pDevice->Present( NULL, NULL, NULL, NULL );
}
}
示例15: Draw
void Draw( void ) override
{
HRESULT hr;
LPDIRECT3DDEVICE9 device = DirectX9::Instance().Device;
hr = device->SetMaterial(&m_Material->mat);
m_Material->tex->Set();
hr = device->DrawIndexedPrimitive(
D3DPT_TRIANGLELIST,
0,
0,
m_Data->m_MaxVertex,
m_Material->start_index,
m_MaxPrimitive);
}