commit f4d455c2f00c0e7b172357c05a01ad2f14b0745e
Author: Simon Howard <fraggle@soulsphere.org>
AuthorDate: Sat Jul 9 15:27:08 2016 -0400
Commit: Simon Howard <fraggle@soulsphere.org>
CommitDate: Sat Jul 9 15:27:08 2016 -0400
video: Set pixel format correctly for rgbabuffer.
When drawing the screen we convert from the 8-bit surface to the
32-bit RGBA surface and then import the surface data into the texture
for hardware rendering. However, the RGBA mask for the 32-bit surface
must match the RGBA format for the screen otherwise the colors may
end up wrong.
Thanks to Ryan Freeman (CSonicGo) for reporting this problem on
Twitter: <https://twitter.com/Sneakernets/status/751612074967568388>
I have not tested this on a Raspberry Pi but I believe this should
fix the problem.
---
src/i_video.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/i_video.c b/src/i_video.c
index 6501a2b5..0b986494 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1004,6 +1004,8 @@ static void SetVideoMode(void)
byte *doompal;
int w, h;
int x, y;
+ unsigned int rmask, gmask, bmask, amask;
+ int unused_bpp;
int flags = 0;
doompal = W_CacheLumpName(DEH_String("PLAYPAL"), PU_CACHE);
@@ -1103,9 +1105,13 @@ static void SetVideoMode(void)
0, 0, 0, 0);
SDL_FillRect(screenbuffer, NULL, 0);
+ // Format of rgbabuffer must match the screen pixel format because we
+ // import the surface data into the texture.
+ SDL_PixelFormatEnumToMasks(SDL_GetWindowPixelFormat(screen), &unused_bpp,
+ &rmask, &gmask, &bmask, &amask);
rgbabuffer = SDL_CreateRGBSurface(0,
SCREENWIDTH, SCREENHEIGHT, 32,
- 0, 0, 0, 0);
+ rmask, gmask, bmask, amask);
SDL_FillRect(rgbabuffer, NULL, 0);
// Set the scaling quality for rendering the intermediate texture into