mirror of
https://github.com/reactos/reactos.git
synced 2024-11-20 06:15:26 +00:00
[OPENGL32] Fix RGB <-> BGR mismatch
Fix CORE-16221
This commit is contained in:
parent
358f947975
commit
08f228577a
1 changed files with 18 additions and 57 deletions
|
@ -616,63 +616,6 @@ static inline ULONG GET_PIXEL_32(ULONG* Buffer)
|
|||
return *Buffer;
|
||||
}
|
||||
|
||||
static inline COLORREF MAKE_COLORREF_8(const struct pixel_format *format, BYTE Color)
|
||||
{
|
||||
BYTE R,G,B;
|
||||
|
||||
if (format->iPixelType == PFD_TYPE_COLORINDEX)
|
||||
return PALETTEINDEX(Color);
|
||||
|
||||
R = (Color & 0x7) << 5;
|
||||
G = (Color & 0x38) << 2;
|
||||
B = Color & 0xC;
|
||||
|
||||
return RGB(R, G, B);
|
||||
}
|
||||
|
||||
static inline COLORREF MAKE_COLORREF_16(const struct pixel_format *format, USHORT Color)
|
||||
{
|
||||
BYTE R,G,B;
|
||||
|
||||
if (format->iPixelType == PFD_TYPE_COLORINDEX)
|
||||
return PALETTEINDEX(Color);
|
||||
|
||||
R = (Color & 0x7) << 5;
|
||||
G = (Color & 0x38) << 2;
|
||||
B = Color & 0xC;
|
||||
|
||||
return RGB(R, G, B);
|
||||
}
|
||||
|
||||
static inline COLORREF MAKE_COLORREF_24(const struct pixel_format *format, ULONG Color)
|
||||
{
|
||||
BYTE R,G,B;
|
||||
|
||||
if (format->iPixelType == PFD_TYPE_COLORINDEX)
|
||||
return PALETTEINDEX(Color);
|
||||
|
||||
R = (Color & 0xFF0000) >> 16;
|
||||
G = (Color & 0x00FF00) >> 8;
|
||||
B = Color & 0xFF;
|
||||
|
||||
return RGB(R, G, B);
|
||||
}
|
||||
|
||||
static inline COLORREF MAKE_COLORREF_32(const struct pixel_format *format, ULONG Color)
|
||||
{
|
||||
BYTE R,G,B;
|
||||
|
||||
if (format->iPixelType == PFD_TYPE_COLORINDEX)
|
||||
return PALETTEINDEX(Color);
|
||||
|
||||
R = (Color & 0xFF0000) >> 16;
|
||||
G = (Color & 0x00FF00) >> 8;
|
||||
B = Color & 0xFF;
|
||||
|
||||
return RGB(R, G, B);
|
||||
}
|
||||
|
||||
|
||||
static inline BYTE PACK_COLOR_8(GLubyte r, GLubyte g, GLubyte b)
|
||||
{
|
||||
return (r & 0x7) | ((g & 0x7) << 3) | ((b & 0x3) << 6);
|
||||
|
@ -769,6 +712,24 @@ static inline void UNPACK_COLORREF_32(COLORREF Color, GLubyte* r, GLubyte* g, GL
|
|||
*b = GetBValue(Color);
|
||||
}
|
||||
|
||||
#define MAKE_COLORREF(__bpp, __type) \
|
||||
static inline COLORREF MAKE_COLORREF_##__bpp(const struct pixel_format *format, __type Color) \
|
||||
{ \
|
||||
GLubyte r,g,b; \
|
||||
\
|
||||
if (format->iPixelType == PFD_TYPE_COLORINDEX) \
|
||||
return PALETTEINDEX(Color); \
|
||||
\
|
||||
UNPACK_COLOR_##__bpp(Color, &r, &g, &b); \
|
||||
\
|
||||
return PACK_COLORREF_##__bpp(r, g, b); \
|
||||
}
|
||||
MAKE_COLORREF(8, BYTE)
|
||||
MAKE_COLORREF(16, USHORT)
|
||||
MAKE_COLORREF(24, ULONG)
|
||||
MAKE_COLORREF(32, ULONG)
|
||||
#undef MAKE_COLORREF
|
||||
|
||||
/*
|
||||
* Set the color index used to clear the color buffer.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue