0
struct tri_vertex 
{ 
    float x, y, z, h;
    D3DCOLOR color;
};

void Draw2DLine(float x1, float y1, float x2, float y2, D3DCOLOR dwColor)
{
    tri_vertex vertices[2] = 
    {
        x1, y1, 0.0f, 1.0f, dwColor,
        x2, y2, 0.0f, 1.0f, dwColor,
    };

    pDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, vertices, sizeof(tri_vertex));
} 


pDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE );
pDevice->SetRenderState( D3DRS_LIGHTING, false ); 
pDevice->SetTexture( NULL, NULL );
pDevice->SetPixelShader( NULL );

// If commented out, the block drawn is black. Otherwise its completely white.
pDevice->SetVertexShader( NULL );

// For transparency 
pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
pDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
pDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
pDevice->SetRenderState(D3DRS_BLENDOP,D3DBLENDOP_ADD);

pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);

I am attempting to draw a simple line using DrawPrimitiveUP(). However the line drawn is either completely black or white depending on the SetVertexShader being nulled. It also doesn't support transparency in either.

John
  • 5,942
  • 3
  • 42
  • 79

1 Answers1

0

However the line drawn is either completely black or white depending on the SetVertexShader being nulled

What do you expected? colored line? Have you set the line color?

It also doesn't support transparency in either.

You set the texture to null, so the blend has no effect to the line.

zdd
  • 8,258
  • 8
  • 46
  • 75
  • Yes the color has been set. It supports transparency in other D3D applications with the texture set to null. – John Jun 08 '14 at 04:22
  • where did you set the colors? I am very int interest in the transparent line, can you show me a picture of that? – zdd Jun 09 '14 at 01:27
  • Its set from the parameter of Draw2DLine() – John Jun 09 '14 at 02:34
  • Would you like to provide a compileable code? I want to have a try. currently I can't figure out anything wrong with the code you provided. – zdd Jun 10 '14 at 06:37