Game Development Reference
In-Depth Information
operator D3DCOLORVALUE* ();
operator CONST D3DCOLORVALUE* () const;
operator D3DCOLORVALUE& ();
operator CONST D3DCOLORVALUE& () const;
// assignment operators
D3DXCOLOR& operator += ( CONST D3DXCOLOR& );
D3DXCOLOR& operator -= ( CONST D3DXCOLOR& );
D3DXCOLOR& operator *= ( FLOAT );
D3DXCOLOR& operator /= ( FLOAT );
// unary operators
D3DXCOLOR operator + () const;
D3DXCOLOR operator - () const;
// binary operators
D3DXCOLOR operator + ( CONST D3DXCOLOR& ) const;
D3DXCOLOR operator - ( CONST D3DXCOLOR& ) const;
D3DXCOLOR operator * ( FLOAT ) const;
D3DXCOLOR operator / ( FLOAT ) const;
friend D3DXCOLOR operator * (FLOAT, CONST D3DXCOLOR& );
BOOL operator == ( CONST D3DXCOLOR& ) const;
BOOL operator != ( CONST D3DXCOLOR& ) const;
#endif //__cplusplus
FLOAT r, g, b, a;
} D3DXCOLOR, *LPD3DXCOLOR;
Note: Observe that the D3DCOLORVALUE and the D3DXCOLOR struc-
ture both have four floating-point components. This leads to the
common notation of treating a color as a 4D vector ( r , g , b , a ). Color
vectors are added, subtracted, and scaled just like regular vectors. On
the other hand, dot and cross products do not make sense for color
vectors, but component-wise multiplication does make sense for col-
ors. Thus, the color-color multiplication operator in the D3DXCOLOR
class performs component-wise multiplication. The symbol
denotes
component-wise multiplication, and it is defined as:
( c 1 , c 2 , c 3 , c 4 )
( k 1 , k 2 , k 3 , k 4 )=( c 1 k 1 , c 2 k 2 , c 3 k 3 , c 4 k 4 ).
We now update our d3dUtility.h file with the following global color
constants:
namespace d3d
{
.
.
.
const D3DXCOLOR
WHITE( D3DCOLOR_XRGB(255, 255, 255) );
const D3DXCOLOR
BLACK( D3DCOLOR_XRGB( 0,
0,
0) );
const D3DXCOLOR
RED( D3DCOLOR_XRGB(255,
0,
0) );
const D3DXCOLOR
GREEN( D3DCOLOR_XRGB( 0, 255,
0) );
const D3DXCOLOR
BLUE( D3DCOLOR_XRGB( 0,
0, 255) );
Search WWH ::




Custom Search