void drawImageEx(int imgID,float imgX,float imgY,int left,int top,int right,int bottom,
float centerX,float centerY,float rot,float scalX,float scalY,bool hantenX,bool hantenY,
int Alpha,int R,int G,int B,int alphaType) //画像の表示
{
int i;
float leftU=(float)left/imgW[imgID],rightU=(float)right/imgW[imgID]; //テクスチャ座標
float topV=(float)top/imgH[imgID],bottomV=(float)bottom/imgH[imgID];
float width=(right-left)*scalX; //幅
float height=(bottom-top)*scalY; //高さ
float tempU;
if(hantenX)
{
tempU=leftU;
leftU=rightU;
rightU=tempU;
}
if(hantenY)
{
tempU=topV;
topV=bottomV;
bottomV=tempU;
}
CUSTOMVERTEX vertices[] =
{
{ (float)(imgX), (float)(imgY), 0.0f, 1.0f, D3DCOLOR_ARGB(Alpha,R,G,B),leftU,topV },
{ (float)(imgX+width),(float)(imgY), 0.0f, 1.0f, D3DCOLOR_ARGB(Alpha,R,G,B), rightU,topV },
{ (float)(imgX),(float)(imgY+height), 0.0f, 1.0f,D3DCOLOR_ARGB(Alpha,R,G,B) , leftU,bottomV },
{ (float)(imgX+width),(float)(imgY+height), 0.0f, 1.0f, D3DCOLOR_ARGB(Alpha,R,G,B), rightU,bottomV },
};
centerX+=imgX; //絶対座標に変換
centerY+=imgY;
for(i=0;i<4;i++)
{
vertices[i].x-=centerX; //回転
vertices[i].y-=centerY;
float tmpX=vertices[i].x,tmpY=vertices[i].y;
vertices[i].x=tmpX*cos(rot)-tmpY*sin(rot);
vertices[i].y=tmpX*sin(rot)+tmpY*cos(rot);
vertices[i].x+=centerX;
vertices[i].y+=centerY;
vertices[i].x+=-0.5f+screenOffsetX;
vertices[i].y+=-0.5f+screenOffsetY;
}
g_pD3DDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
D3DXMATRIX txz;
D3DXMatrixIdentity(&txz);
g_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP , D3DTOP_MODULATE );
g_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
g_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
g_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP , D3DTOP_MODULATE );
g_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); // 板ポリのα値を利用
g_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE); //アルファブレンディングの有効化
if(alphaType==0)
{
g_pD3DDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
g_pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); //SRCの設定
g_pD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);//DESTの設定
}
else if(alphaType==1)
{
g_pD3DDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
g_pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
g_pD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
}
else if(alphaType==2)
{
g_pD3DDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_REVSUBTRACT);
g_pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
g_pD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
}
g_pD3DDevice->SetTexture(0,img[imgID]);
g_pD3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
g_pD3DDevice->SetTransform( D3DTS_TEXTURE0, &txz);
g_pD3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_DISABLE);
g_pD3DDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP,2,vertices,sizeof(CUSTOMVERTEX) );
}