I am using DirectDraw to make a game and I am running it in 8-bit color mode. What I am having a problem with is making a macro to convert RGB values into a single 8-bit color.
Here is the macro:
#define RGB_8BIT(r, g, b) ((r & 224) + ((g & 224) >> 3) + (b >> 6))
Here's my setPixel function:
VOID setPixel(INT x, INT y, BYTE color)
{
lpScreen[x + y * lPitch] = color;
}
lpScreen is defined as an array of BYTEs.
And here is the implementation in WinMain:
setPixel(0, 0, RGB_8BIT(255, 0, 0));
For some reason, this comes out as a greenish-blue when it should be pure red.