我需要将传递给函数的整数 RGB 颜色转换为介于 0 和 1 之间的 shift double alpha,然后将其推回浮点数组。
#define __GETR(x) ((x & 0x0000FF))
#define __GETG(x) ((x & 0x00FF00)>>8)
#define __GETB(x) ((x & 0xFF0000)>>16)
// NOTE: The vertex format for this class should be written so that color is an integer and not float.
void AddColor(int col, double alpha)
{
vertices.push_back(D3DCOLOR_RGBA(__GETR(col), __GETG(col), __GETB(col), (int)alpha*255));
useColors = true;
}