Some nice anti-aliased text with DirectX

Started by
3 comments, last by Eric 23 years, 8 months ago
I have an image which contains alpha info. How should I render it over my 3D scene? (I am displaying some game stats; the image is an anti-aliased font character which I created in my art program.) Right now I am thinking I will have to set the image as the texture for a camera-faced primitive. I like this approach particularly because I won''t have to worry about pixel formats, plus it''s all I could come up with. Any other suggestions, though?
Advertisement
Why not render with pretransformed coordinates, like D3DTLVERTEX?

- WitchLord

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Assuming I understand the question, why not just blt to the back buffer over the 3d image?
You cannot alpha blit using BitBlt.. you have to use a texture for that...

The pretransformed coordinates are necessary because you want
the texture to appear at the same SCREEN coordinates all the
time. Using world-coordinates (i.e. using an untransformed
primitive) will probably make it wobble a bit due to round-off
errors.
--- axelP
Here''s how to draw 2D image with alpha as a polygon:

1. Set states:
D3DRENDERSTATE_SRCBLEND = D3DBLEND_SRCALPHA
D3DRENDERSTATE_DESTBLEND = D3DBLEND_INVSRCALPHA
D3DRENDERSTATE_ALPHABLENDENABLE = true
D3DRENDERSTATE_ZENABLE = false
SetTexture( ... )

2. Do this...

void fill_rectangle( float x1, float y1, float x2, float y2, D3DCOLOR color, float z = 0.5, float rhw = 0.5 )
{
D3DTLVERTEX v[4];

if( x2 > x1 ) x2++; else x1++;
if( y2 > y1 ) y2++; else y1++;
v[0] = D3DTLVERTEX( D3DVECTOR( x1, y2, z ), rhw, color, 0, 0, 1 );
v[1] = D3DTLVERTEX( D3DVECTOR( x1, y1, z ), rhw, color, 0, 0, 0 );
v[2] = D3DTLVERTEX( D3DVECTOR( x2, y2, z ), rhw, color, 0, 1, 1 );
v[3] = D3DTLVERTEX( D3DVECTOR( x2, y1, z ), rhw, color, 0, 1, 0 );

DXFramework->DrawPrimitive( D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX, v, 4, 0 );
}

This topic is closed to new replies.

Advertisement