All pastes #430443 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-04-08 23:55 UTC
rendered paste body
void TriangeTwo()
{

CUSTOMVERTEX g_Vertices[] = 
{ 
    { 200, 400.0f, 0.0f, 0.0f,  D3DCOLOR_XRGB(0,255,0), }, // x, y, z, color 
    { 200.0f, -1.0f, 0.0f, 0.0f,  D3DCOLOR_XRGB(255,0,0), }, 
    { 140.0f, -1.0f, 0.0f,0.0f,  D3DCOLOR_XRGB(255,0,0), }, 
};

IDirect3DVertexBuffer9* pVertexBuf = NULL;
HRESULT hR = g_pDirect3DDevice->CreateVertexBuffer(3*sizeof(CUSTOMVERTEX),0 , D3DFVF_XYZRHW | D3DFVF_DIFFUSE, D3DPOOL_DEFAULT , &pVertexBuf , NULL);
    
VOID* pVertices;
hR = pVertexBuf->Lock(0, 0, (void**)&pVertices, 0); 

memcpy( pVertices, g_Vertices, sizeof(g_Vertices) ); 
pVertexBuf->Unlock();

g_pDirect3DDevice->SetStreamSource( 0, pVertexBuf, 0 , sizeof(CUSTOMVERTEX) );
g_pDirect3DDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);

D3DXMATRIX matWorld;
D3DXMatrixRotationY( &matWorld, timeGetTime()/150.0f );
g_pDirect3DDevice->SetTransform( D3DTS_WORLD, &matWorld );

D3DXVECTOR3 vEyePt   ( 0.0f, 3.0f,-5.0f );
D3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f );
D3DXVECTOR3 vUpVec   ( 0.0f, 1.0f, 0.0f );
D3DXMATRIXA16 matView;
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
g_pDirect3DDevice->SetTransform( D3DTS_VIEW, &matView );

D3DXMATRIX matProj;
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f );
g_pDirect3DDevice->SetTransform( D3DTS_PROJECTION, &matProj );







g_pDirect3DDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );

}