本文整理汇总了C++中LPDIRECT3DDEVICE9::DrawPrimitive方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3DDEVICE9::DrawPrimitive方法的具体用法?C++ LPDIRECT3DDEVICE9::DrawPrimitive怎么用?C++ LPDIRECT3DDEVICE9::DrawPrimitive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3DDEVICE9
的用法示例。
在下文中一共展示了LPDIRECT3DDEVICE9::DrawPrimitive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenderQuad
void RenderQuad()
{
// Setup texture
g_pd3dDevice->SetTexture(0, g_pRenderTexture) ;
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP );
g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP );
// Set stream source
g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(Vertex) );
g_pd3dDevice->SetFVF(VertexFVF) ;
g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2) ;
}
示例2: sizeof
VOID jcd3d::jcd3d_display(DWORD timeDelta)
{
if(lpd3dd)
{
lpd3dd->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x000000, 1.0f, 0);
lpd3dd->BeginScene();
lpd3dd->SetStreamSource(0, lpd3dvb, 0, sizeof(JCVertex));
lpd3dd->SetFVF(JCVertex::fvf);
lpd3dd->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
lpd3dd->EndScene();
lpd3dd->Present(NULL, NULL, NULL, NULL);
}
}
示例3:
// @brief : 描画
// @param : 描画の種類
//--------------------------------------------------------------------
void Vertex3dCol::Draw(const TYPE &_type, const UINT &_prim_count)
{
const D3DPRIMITIVETYPE type[MAX_TYPE] =
{
D3DPT_POINTLIST,
D3DPT_LINELIST,
D3DPT_LINESTRIP,
D3DPT_TRIANGLELIST,
D3DPT_TRIANGLESTRIP
};
HRESULT hr;
LPDIRECT3DDEVICE9 device = DirectX9::Instance().Device;
hr = device->SetStreamSource(0,m_Buffer,0,sizeof(VERTEX_DX));
hr = device->SetFVF(FVF);
hr = device->DrawPrimitive(type[_type],0,_prim_count);
}
示例4: RenderQuad
void RenderQuad()
{
// Setup texture
g_pd3dDevice->SetTexture(0, g_pTexture) ;
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
g_pd3dDevice->SetSamplerState(0, D3DSAMP_BORDERCOLOR, 0xffff0000) ; // border color: red
g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, g_AddressMode );
g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, g_AddressMode );
// Set stream source
g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(Vertex) );
g_pd3dDevice->SetFVF(VertexFVF) ;
g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2) ;
}
示例5: Draw
void DxPoint::Draw(
const float& positionX,
const float& positionY,
const float& positionZ,
const float& scale,
bool textureBlend)
{
LPDIRECT3DDEVICE9 pDevice = D3DManager::getInstance()->getDevice();
D3DXMATRIX matPos;
D3DXMatrixTranslation(&matPos, positionX, positionY, positionZ);
pDevice->SetTransform(D3DTS_WORLD, &matPos);
pDevice->SetRenderState(D3DRS_POINTSCALEENABLE, TRUE);
pDevice->SetRenderState(D3DRS_POINTSCALE_A, 0);
pDevice->SetRenderState(D3DRS_POINTSCALE_B, 0);
pDevice->SetRenderState(D3DRS_POINTSCALE_C, 1036831949);
pDevice->SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&scale));
if (textureBlend)
{
pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
}
pDevice->SetStreamSource(0, mp_vertexBuffer, 0, sizeof(POINT_CUSTOMVERTEX));
pDevice->SetFVF(POINT_CUSTOMVERTEX::D3DFVF_POINT);
if (mp_texture)
{
pDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE);
pDevice->SetTexture(0, mp_texture);
}
pDevice->DrawPrimitive(D3DPT_POINTLIST, 0, 1);
if (mp_texture)
{
pDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, FALSE);
}
pDevice->SetRenderState(D3DRS_POINTSCALEENABLE, FALSE);
if (textureBlend)
{
pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
}
}
示例6: render_particle
// this function renders the particle
void Particles::render_particle(LPDIRECT3DDEVICE9 d3ddev, int a)
{
//d3ddev->SetFVF(CUSTOMFVF);
if(a == 1){
d3ddev->SetStreamSource(0, f_buffer, 0, sizeof(CUSTOMVERTEX2));
}
else{
d3ddev->SetStreamSource(0, t_buffer, 0, sizeof(CUSTOMVERTEX1));
}
if(a == 1)
d3ddev->SetTexture(0, texture1);
else
d3ddev->SetTexture(0, texture);
d3ddev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 1);
return;
}
示例7: Render
void HealthBar::Render(LPDIRECT3DDEVICE9 pDevice)
{
pDevice->SetTexture(0, NULL);
pDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
/*D3DMATERIAL9 material;
::memset(&material, 0, sizeof(D3DMATERIAL9));
material.Diffuse = D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f);
pDevice->SetMaterial(&material);*/
pDevice->SetFVF(LITVERTEX::GetFVF());
pDevice->SetStreamSource(0, m_pVertBuf, 0, sizeof(LITVERTEX));
pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2);
pDevice->SetRenderState(D3DRS_LIGHTING, TRUE);
}
示例8: RenderDX
//**************************Render and display the scene in DirectX***********************
void RenderDX()
{
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );
// Begin the scene
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
// Rendering of scene objects can happen here
g_pd3dDevice->SetStreamSource( 0, vbo, 0, sizeof(CUSTOMVERTEX) );
g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );
// End the scene
g_pd3dDevice->EndScene();
}
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
示例9: sizeof
void DX9LineRenderer::render(const Group& group)
{
HRESULT hr;
if( !DX9PrepareBuffers(group) )
return;
if (!prepareBuffers(group))
return;
initBlending();
if( group.getNbParticles() != 0 )
{
for (size_t i = 0; i < group.getNbParticles(); ++i)
{
const Particle& particle = group.getParticle(i);
D3DCOLOR c = D3DCOLOR_COLORVALUE(particle.getR(), particle.getG(), particle.getB(), particle.getParamCurrentValue(PARAM_ALPHA));
Assign((gpuIterator)->position, particle.position());
(gpuIterator++)->color = c;
Assign((gpuIterator)->position, (particle.position() + particle.velocity() * length));
(gpuIterator++)->color = c;
}
void *ptr;
if( DX9VertexBuffer->Lock(0, 0, &ptr, 0) == D3D_OK )
{
std::memcpy(ptr, gpuBuffer, group.getNbParticles() * 2 * sizeof(LineVertex));
if( DX9VertexBuffer->Unlock() == D3D_OK )
{
LPDIRECT3DDEVICE9 device = DX9Info::getDevice();
device->SetFVF(D3DFVF_XYZ|D3DFVF_DIFFUSE);
device->SetStreamSource(0, DX9VertexBuffer, 0, sizeof(LineVertex));
device->DrawPrimitive(D3DPT_LINELIST, 0, group.getNbParticles());
}
}
}
}
示例10: Render
VOID Render()
{
if( !g_pd3dDevice ) return;
LPDIRECT3DDEVICE9 d = g_pd3dDevice;
d->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
if( SUCCEEDED( d->BeginScene() ) ) {
SetupLights();
SetupMatrices();
d->SetStreamSource( 0, g_pVertexBuff, 0, sizeof(CUSTOMVERTEX) );
d->SetFVF( D3DFVF_CUSTOMVERTEX );
d->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 * 50 - 2 );
//d->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME );
d->EndScene();
}
d->Present( NULL, NULL, NULL, NULL );
}
示例11:
//***************************************************************
// 描画
// 引数:
// LPDIRECT3DDEVICE9 pDevice:デバイスポインタ
// 戻り値:
// なし
//***************************************************************
void CTitle2d::Draw(LPDIRECT3DDEVICE9 pDevice)
{
//テクスチャ取得変数
LPDIRECT3DTEXTURE9 Texture = CTexture::GetTexture(m_nTex);
//アンロック変数
VERTEX_2D *pv;
//ロック解除
m_pD3DVtxBuff->Lock(0,0,(void**)&pv,0);
//画像の初期化の流れ
//座標x,y,z
pv[0].vtx = D3DXVECTOR3(m_Vertex_2d.vtx.x, m_Vertex_2d.vtx.y, 0.0f);
pv[1].vtx = D3DXVECTOR3(m_Vertex_2d.vtx.x + m_Vertex_2d.Scail.x, m_Vertex_2d.vtx.y,0.0f);
pv[2].vtx = D3DXVECTOR3(m_Vertex_2d.vtx.x, m_Vertex_2d.vtx.y + m_Vertex_2d.Scail.y,0.0f);
pv[3].vtx = D3DXVECTOR3(m_Vertex_2d.vtx.x + m_Vertex_2d.Scail.x,m_Vertex_2d.vtx.y + m_Vertex_2d.Scail.y,0.0f);
//頂点色(赤、緑、青)
pv[0].diffuse = m_Vertex_2d.diffuse;
pv[1].diffuse = m_Vertex_2d.diffuse;
pv[2].diffuse = m_Vertex_2d.diffuse;
pv[3].diffuse = m_Vertex_2d.diffuse;
//ロック
m_pD3DVtxBuff->Unlock();
//フォーマットの指定
pDevice->SetFVF(FVF_VERTEX_2D);
//テクスチャ設定
pDevice->SetTexture(0,
Texture);
//頂点バッファの送信
pDevice->SetStreamSource(0,m_pD3DVtxBuff,0,sizeof(VERTEX_2D));
//画像表示
pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2);
}
示例12: render_frame
// this is the function used to render a single frame
void render_frame(void)
{
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
d3ddev->BeginScene();
// select which vertex format we are using
d3ddev->SetFVF(CUSTOMFVF);
// select the vertex buffer to display
d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX));
// copy the vertex buffer to the back buffer
d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
d3ddev->EndScene();
d3ddev->Present(NULL, NULL, NULL, NULL);
}
示例13: Render
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//-----------------------------------------------------------------------------
VOID Render()
{
// Clear the backbuffer and the zbuffer
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB( 0, 0, 255 ), 1.0f, 0 );
D3DLOCKED_RECT locked;
if(g_pTexture->LockRect(0, &locked, NULL, /*D3DLOCK_DISCARD*/0)==D3D_OK)
{
memcpy(locked.pBits, videoFrame, TEXTURE_WIDTH*TEXTURE_HEIGHT*3);
g_pTexture->UnlockRect(0);
}
// Begin the scene
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
// Setup the world, view, and projection matrices
SetupMatrices();
// Setup our texture. Using textures introduces the texture stage states,
// which govern how textures get blended together (in the case of multiple
// textures) and lighting information. In this case, we are modulating
// (blending) our texture with the diffuse color of the vertices.
g_pd3dDevice->SetTexture( 0, g_pTexture );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
// Render the vertex buffer contents
g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof( CUSTOMVERTEX ) );
g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
// Draws two triangles (makes a quad that will support our drone video picture)
g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
// End the scene
g_pd3dDevice->EndScene();
}
// Present the backbuffer contents to the display
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
示例14: Render
void Render(float timeDelta)
{
if (!g_bActive)
{
Sleep(50) ;
}
SetupMatrix() ;
// Clear the back-buffer to a RED color
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );
// Begin the scene
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
// Render state
g_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
g_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE );
g_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
g_pd3dDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE) ;
g_pd3dDevice->SetRenderState(D3DRS_POINTSCALEENABLE, TRUE) ;
g_pd3dDevice->SetRenderState( D3DRS_POINTSIZE, FtoDW(0.2f) );
// Set texture
g_pd3dDevice->SetTexture(0, g_pTexture) ;
// Draw points
g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(POINTVERTEX));
g_pd3dDevice->SetFVF(D3DFVF_POINTVERTEX) ;
g_pd3dDevice->DrawPrimitive( D3DPT_POINTLIST, 0, NUM_VERTEX) ;
// Restore state
g_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
// End the scene
g_pd3dDevice->EndScene();
}
// Present the back-buffer contents to the display
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
示例15: DrawPointSprite
// ポイントスプライトを描画する
void Object::DrawPointSprite(Vertex3 point[], int numPoint, Texture &texture)
{
Vertex3 *vertex;
pointBuffer->Lock(0, 0, (LPVOID*)&vertex, 0);
for (int i = 0; i < numPoint; i++)
{
// ポイントスプライトの位置の計算
vertex[i].pos = point[i].pos;
// ポイントスプライトのサイズを設定
vertex[i].size = point[i].size;
// ポイントスプライトの色を設定
vertex[i].color = point[i].color;
}
pointBuffer->Unlock();
// テクスチャをパイプラインにセット
d3dDevice->SetTexture(0, texture.texture);
// ワールド変換マトリックスをパイプラインにセット
D3DXMATRIX m_world;
D3DXMatrixIdentity(&m_world);
d3dDevice->SetTransform(D3DTS_WORLD, &m_world);
//アルファブレンディングを行う
d3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
d3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
d3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
// ポイントスプライトの描画
d3dDevice->SetRenderState(D3DRS_ZENABLE, true); // Z比較を行わない
d3dDevice->SetStreamSource(0, pointBuffer, 0, sizeof(Vertex3));
d3dDevice->SetFVF(VERTEX3_FVF);
d3dDevice->DrawPrimitive(D3DPT_POINTLIST, 0, numPoint);
d3dDevice->SetRenderState(D3DRS_ZENABLE, true); // Z比較を行う
//アルファブレンドを終わらせる
d3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
}