So this sample draw a triangle with three color points, or a blending color triangle?
HRESULT InitVB()
{
//user's data of the points
CUSTOMVERTEX vertices[] =
{
{ 100.0f, 400.0f, 0.5f, 1.0f, 0xffff0000, },
{ 300.0f, 50.0f, 0.5f, 1.0f, 0xff00ff00, },
{ 500.0f, 400.0f, 0.5f, 1.0f, 0xff0000ff, },
};
//creat the point buffer area
if( FAILED( g_pd3dDevice->CreateVertexBuffer( 3*sizeof(CUSTOMVERTEX),
0, D3DFVF_CUSTOMVERTEX,
D3DPOOL_DEFAULT, &g_pVB, NULL ) ) )
{
return E_FAIL;
}
//blend
VOID* pVertices;
if( FAILED( g_pVB->Lock( 0, sizeof(vertices), (void**)&pVertices, 0 ) ) )
return E_FAIL;
memcpy( pVertices, vertices, sizeof(vertices) );
g_pVB->Unlock();
return S_OK;
}