Well I just ported Hans DrawBox which supports Alpha blending, but I get all weird shit in the test9.exe environment, can someone confirm his function still works???
Hans DrawBox:
Code:
void DrawBox(pD3DdeviceX pDevice, int x, int y, int w, int h, D3DCOLOR col)
{
struct {
float x,y,z,rhw;
DWORD dwColor;
} qV[4] = { { (float)x , (float)(y+h), 0.0f, 0.0f, col},
{ (float)x , (float)y , 0.0f, 0.0f, col},
{ (float)(x+w), (float)(y+h), 0.0f, 0.0f, col},
{ (float)(x+w), (float)y , 0.0f, 0.0f, col} };
pDevice->SetPixelShader(NULL);
pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true);
pDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
pDevice->SetTexture(0, NULL);
pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,qV,sizeof(qV[0]));
}
Mine Ported to Delphi:
[highlight=delphi]
procedure DrawBox(const iXleft, iYtop, iWidth, iHight: Integer; d3dARGB : D3DCOLOR);
type
tVertex = packed record
x, y, z, rhw: Single;
Color: D3DCOLOR;
end;
procedure AssignVertex(var Vertex: tVertex; x, y, z, rhw: Single; Color: D3DCOLOR);
begin
Vertex.x:= x; Vertex.y:= y; Vertex.z:= z; Vertex.rhw:= rhw;
Verte*****lor:= Color;
end;
var
qV: array[0..3] of tVertex;
begin
AssignVertex(qV[0], iXLeft, iYtop + iHight, 0.0, 0.0, d3dARGB);
AssignVertex(qV[1], iXLeft, iYtop, 0.0, 0.0, d3dARGB);
AssignVertex(qV[2], iXLeft + iWidth, iYtop + iHight, 0.0, 0.0, d3dARGB);
AssignVertex(qV[3], iXLeft + iWidth, iYtop, 0.0, 0.0, d3dARGB);
GetDevice.SetPixelShader(Nil);
GetDevice.SetRenderState(D3DRS_ALPHABLENDENABLE,1) ;
GetDevice.SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ INVSRCALPHA);
GetDevice.SetTexture(0, Nil);
GetDevice.DrawPrimitiveUP(D3DPT_LINESTRIP,2,qV,Siz eOf(qV[0]));
//Old DrawRetangle
//GetDevice.Clear(1,@
D3DRectangle, D3DCLEAR_TARGET, d3dARGB, 0, 0);
end;
[/highlight]