Always use SDL_Map(A)RGB in SDL_FillRect for color
authorWuzzy <Wuzzy2@mail.ru>
Mon, 16 Jul 2018 19:15:22 +0200
changeset 13490 8935dcc0e130
parent 13489 dbf4f7a677be
child 13491 4faebbf9c44f
Always use SDL_Map(A)RGB in SDL_FillRect for color This practice is recommended by official SDL docs.
hedgewars/uRenderUtils.pas
hedgewars/uStore.pas
--- a/hedgewars/uRenderUtils.pas	Mon Jul 16 04:50:23 2018 +0200
+++ b/hedgewars/uRenderUtils.pas	Mon Jul 16 19:15:22 2018 +0200
@@ -46,7 +46,7 @@
 begin
     r:= rect^;
     if Clear then
-        SDL_FillRect(Surface, @r, 0);
+        SDL_FillRect(Surface, @r, SDL_MapRGB(Surface^.format, 0, 0, 0));
 
     BorderColor:= SDL_MapRGB(Surface^.format, BorderColor shr 16, BorderColor shr 8, BorderColor and $FF);
     FillColor:= SDL_MapRGB(Surface^.format, FillColor shr 16, FillColor shr 8, FillColor and $FF);
@@ -554,7 +554,7 @@
     rect.h:= textHeight + cornerHeight * 2 - edgeHeight * 2;
     i:= rect.w;
     j:= rect.h;
-    SDL_FillRect(finalSurface, @rect, cWhiteColor);
+    SDL_FillRect(finalSurface, @rect, SDL_MapRGB(finalSurface^.format, cWhiteColor shr 16, cWhiteColor shr 8, cWhiteColor and $FF));
 
     pos:= 1; line:= 0;
     while GetNextSpeechLine(s, #1, pos, substr) do
--- a/hedgewars/uStore.pas	Mon Jul 16 04:50:23 2018 +0200
+++ b/hedgewars/uStore.pas	Mon Jul 16 19:15:22 2018 +0200
@@ -975,7 +975,7 @@
 r.y:= cFontBorder + 4;
 r.w:= 32;
 r.h:= 32;
-SDL_FillRect(tmpsurf, @r, $ff000000);
+SDL_FillRect(tmpsurf, @r, SDL_MapRGB(tmpsurf^.format, 0, 0, 0));
 SDL_UpperBlit(iconsurf, iconrect, tmpsurf, @r);
 
 RenderHelpWindow:=  Surface2Tex(tmpsurf, true);