Code:
void DrawTexBox(
__in LPDIRECT3DDEVICE9 pDevice,
__in LPDIRECT3DTEXTURE9 pTexture,
__in int x,
__in int y,
__in int w,
__in int h);
Parameters
pDevice [in]
LPDIRECT3DDEVICE9
Pointer to an IDirect3DDevice9 interface, the device to be associated with the drawing of the object.
pTexture [in]
LPDIRECT3DTEXTURE9
Pointer to an LPDIRECT3DTEXTURE9 interface, the texture that will be mapped around the primitive.
X [in]
INT
Specifies the x-coordinate of the rectangle''s upper-left corner.
Y [in]
INT
Specifies the y-coordinate of the rectangle''s upper-left corner.
W (Weight) [in]
INT
The width of the Square in logical units.
H (Height) [in]
INT
The height of the Square in logical units.
Code:
void DrawTexBox(LPDIRECT3DDEVICE9 pDevice,
LPDIRECT3DTEXTURE9 pTexture,
int x,
int y,
int w,
int h)
{
struct tVertex
{
float X, Y, Z, RHW;
float IU, IV;
enum FVF
{
FVF_Flags = (D3DFVF_XYZRHW | D3DFVF_TEX1)
};
};
tVertex Veri[4] =
{
{(float)x ,(float)y , 0.0f, 1.0f, 0.0f, 0.0f },
{(float)(x+w) ,(float)y , 0.0f, 1.0f, 1.0f, 0.0f },
{(float)x ,(float)(y+h) , 0.0f, 1.0f, 0.0f, 1.0f },
{(float)(x+w) ,(float)(y+h) , 0.0f, 1.0f, 1.0f, 1.0f },
};
pDevice->SetTexture( 0, pTexture );
//
// Credit mmbob for helping fixing the problem
//
pDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
pDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
pDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_TEXTURE );
pDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE );
//
// Credit mmbob for helping fixing the problem
//
pDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
pDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
////////////////////////////////////
pDevice->SetRenderState( D3DRS_LIGHTING, FALSE);
pDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW);
pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
pDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
pDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );
pDevice->SetRenderState( D3DRS_FOGENABLE, false );
pDevice->SetFVF( tVertex::FVF_Flags );
pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,Veri,sizeof(tVertex));
}