Direct3D 9学习笔记(5)颜色
2012-08-07 22:42
155 查看
一.三个宏
// D3DCOLOR is equivalent to D3DFMT_A8R8G8B8 #ifndef D3DCOLOR_DEFINED typedef DWORD D3DCOLOR; #define D3DCOLOR_DEFINED #endif // maps unsigned 8 bits/channel to D3DCOLOR #define D3DCOLOR_ARGB(a,r,g,b) \ ((D3DCOLOR)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) #define D3DCOLOR_RGBA(r,g,b,a) D3DCOLOR_ARGB(a,r,g,b) #define D3DCOLOR_XRGB(r,g,b) D3DCOLOR_ARGB(0xff,r,g,b)
返回的是一个DWORD
二.D3DXCOLOR,D3DCOLORVALUE
一个更精确的存储颜色的数据结构typedef struct _D3DCOLORVALUE { float r; float g; float b; float a; } D3DCOLORVALUE;
typedef struct D3DXCOLOR { #ifdef __cplusplus public: D3DXCOLOR() {}; D3DXCOLOR( UINT argb ); D3DXCOLOR( CONST FLOAT * ); D3DXCOLOR( CONST D3DXFLOAT16 * ); D3DXCOLOR( FLOAT r, FLOAT g, FLOAT b, FLOAT a ); // casting operator UINT () const; operator FLOAT* (); operator CONST FLOAT* () 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;
三.顶点着色
如下顶点颜色填充效果
设置方法
有颜色的顶点坐标
// Initialize three Vertices for rendering a triangle CUSTOMVERTEX Vertices[] = { { 150.0f, 50.0f, 0.5f, 1.0f, 0xffff0000, }, // x, y, z, rhw, color { 250.0f, 250.0f, 0.5f, 1.0f, 0xff00ff00, }, { 50.0f, 250.0f, 0.5f, 1.0f, 0xff00ffff, }, };
相关文章推荐
- 【HTML5学习笔记】18:CSS颜色和度量单位
- opencv学习笔记之五 颜色空间
- 【阅读笔记之六】《DIRECTX.9.0.3D游戏开发编程基础》:Direct3D中的颜色
- Direct3D 9学习笔记(11)网格(Mesh)2
- 【opencv学习笔记】2用摄像头识别指定颜色
- 20160114html学习笔记表单框架颜色脚本字符实体
- DirectX 11游戏编程学习笔记之8: 第6章Drawing in Direct3D(在Direct3D中绘制)(习题解答)
- Kinect开发学习笔记之(四)提取颜色数据并用OpenCV显示(转)
- 【OpenCV学习笔记】【函数学习】五(颜色空间转换cvCvtColor()函数)
- .Net学习笔记----2015-07-02(选择文件对话框、保存对话框、字体和颜色对话框)
- jquery学习笔记1表格颜色交叉展示
- openCV学习笔记-颜色通道的分离和混合
- cocos2d-js学习笔记---场景转换(scene),颜色图层,变量获得
- Direct-X学习笔记--Alpha颜色混合
- Kinect开发学习笔记之(四)提取颜色数据并用OpenCV显示
- HTML&CSS基础学习笔记1.28-颜色的表达
- R语言学习笔记---颜色作图篇(二)
- 【Direct3D游戏开发】——蒙皮骨骼动画学习笔记
- j2me学习笔记【13】——创建矩形框、圆角矩形以及填充颜色小例子
- MFC学习笔记(1)——颜色、图片简单自绘