D3DXColor的操作
2013-02-05 11:38 Clingingboy 阅读(693) 评论(0) 编辑 收藏 举报
参考:
http://blog.csdn.net/caimouse/article/details/120888
http://blog.csdn.net/caimouse/article/details/120863
http://blog.csdn.net/caimouse/article/details/120597
//--------------------------
// Color
//--------------------------
D3DX10INLINE D3DXCOLOR* D3DXColorNegative
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC)
{
#ifdef D3DX10_DEBUG
if(!pOut || !pC)
return NULL;
#endif
pOut->r = 1.0f - pC->r;
pOut->g = 1.0f - pC->g;
pOut->b = 1.0f - pC->b;
pOut->a = pC->a;
return pOut;
}
D3DX10INLINE D3DXCOLOR* D3DXColorAdd
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2)
{
#ifdef D3DX10_DEBUG
if(!pOut || !pC1 || !pC2)
return NULL;
#endif
pOut->r = pC1->r + pC2->r;
pOut->g = pC1->g + pC2->g;
pOut->b = pC1->b + pC2->b;
pOut->a = pC1->a + pC2->a;
return pOut;
}
D3DX10INLINE D3DXCOLOR* D3DXColorSubtract
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2)
{
#ifdef D3DX10_DEBUG
if(!pOut || !pC1 || !pC2)
return NULL;
#endif
pOut->r = pC1->r - pC2->r;
pOut->g = pC1->g - pC2->g;
pOut->b = pC1->b - pC2->b;
pOut->a = pC1->a - pC2->a;
return pOut;
}
D3DX10INLINE D3DXCOLOR* D3DXColorScale
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s)
{
#ifdef D3DX10_DEBUG
if(!pOut || !pC)
return NULL;
#endif
pOut->r = pC->r * s;
pOut->g = pC->g * s;
pOut->b = pC->b * s;
pOut->a = pC->a * s;
return pOut;
}
D3DX10INLINE D3DXCOLOR* D3DXColorModulate
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2)
{
#ifdef D3DX10_DEBUG
if(!pOut || !pC1 || !pC2)
return NULL;
#endif
pOut->r = pC1->r * pC2->r;
pOut->g = pC1->g * pC2->g;
pOut->b = pC1->b * pC2->b;
pOut->a = pC1->a * pC2->a;
return pOut;
}
D3DX10INLINE D3DXCOLOR* D3DXColorLerp
(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s)
{
#ifdef D3DX10_DEBUG
if(!pOut || !pC1 || !pC2)
return NULL;
#endif
pOut->r = pC1->r + s * (pC2->r - pC1->r);
pOut->g = pC1->g + s * (pC2->g - pC1->g);
pOut->b = pC1->b + s * (pC2->b - pC1->b);
pOut->a = pC1->a + s * (pC2->a - pC1->a);
return pOut;
}