# HG changeset patch # User sheepluva # Date 1480813338 -3600 # Node ID 51596d30a7249201cbc0c30fd6e9ebabac758c34 # Parent 2e70ef81e281f2a707a02b6a0b514720d0d16a99 fix chat SDL surfaces being in wrong color format (didn't play well with copyToXY's new quick pixel copies) diff -r 2e70ef81e281 -r 51596d30a724 hedgewars/SDLh.pas --- a/hedgewars/SDLh.pas Sun Dec 04 01:07:36 2016 +0100 +++ b/hedgewars/SDLh.pas Sun Dec 04 02:02:18 2016 +0100 @@ -1052,7 +1052,7 @@ procedure SDL_FreeSurface(Surface: PSDL_Surface); cdecl; external SDLLibName; function SDL_SetColorKey(surface: PSDL_Surface; flag, key: LongWord): LongInt; cdecl; external SDLLibName; function SDL_SetAlpha(surface: PSDL_Surface; flag, key: LongWord): LongInt; cdecl; external SDLLibName; -function SDL_ConvertSurface(src: PSDL_Surface; fmt: PSDL_PixelFormat; flags: LongInt): PSDL_Surface; cdecl; external SDLLibName; +function SDL_ConvertSurface(src: PSDL_Surface; fmt: PSDL_PixelFormat; flags: LongWord): PSDL_Surface; cdecl; external SDLLibName; function SDL_UpperBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): LongInt; cdecl; external SDLLibName; function SDL_FillRect(dst: PSDL_Surface; dstrect: PSDL_Rect; color: LongWord): LongInt; cdecl; external SDLLibName; diff -r 2e70ef81e281 -r 51596d30a724 hedgewars/uChat.pas --- a/hedgewars/uChat.pas Sun Dec 04 01:07:36 2016 +0100 +++ b/hedgewars/uChat.pas Sun Dec 04 02:02:18 2016 +0100 @@ -161,7 +161,7 @@ * It will use the color stored in cl and update width *) procedure RenderChatLineTex(var cl: TChatLine; var str: shortstring); -var strSurface, +var strSurface, tmpSurface, resSurface: PSDL_Surface; dstrect : TSDL_Rect; // destination rectangle for blitting font : THWFont; @@ -194,10 +194,14 @@ SDL_FillRect(resSurface, @dstrect, shadowint); // create and blit text +tmpSurface:= nil; strSurface:= TTF_RenderUTF8_Blended(Fontz[font].Handle, Str2PChar(str), cl.color); +// fix format +if strSurface <> nil then tmpSurface:= SDL_ConvertSurface(strSurface, resSurface^.format, 0); +SDL_FreeSurface(strSurface); //SDL_UpperBlit(strSurface, nil, resSurface, @dstrect); -if strSurface <> nil then copyToXY(strSurface, resSurface, Padding, Padding); -SDL_FreeSurface(strSurface); +if tmpSurface <> nil then copyToXY(tmpSurface, resSurface, Padding, Padding); +SDL_FreeSurface(tmpSurface); cl.Tex:= Surface2Tex(resSurface, false); diff -r 2e70ef81e281 -r 51596d30a724 hedgewars/uRenderUtils.pas --- a/hedgewars/uRenderUtils.pas Sun Dec 04 01:07:36 2016 +0100 +++ b/hedgewars/uRenderUtils.pas Sun Dec 04 02:02:18 2016 +0100 @@ -210,7 +210,8 @@ bT:= (bD * (255 - aT) + bT * aT) div 255; aT:= aD + ((255 - LongInt(aD)) * aT div 255); - destPixels^[dpi]:= SDL_MapRGBA(dest^.format, rT, gT, bT, aT); + destPixels^[dpi]:= SDL_MapRGBA(dest^.format, rT, gT, bT, Byte(aT)); + end; SDL_UnlockSurface(src);