159 |
159 |
160 (* This procedure [re]renders a texture showing str for the chat line cl. |
160 (* This procedure [re]renders a texture showing str for the chat line cl. |
161 * It will use the color stored in cl and update width |
161 * It will use the color stored in cl and update width |
162 *) |
162 *) |
163 procedure RenderChatLineTex(var cl: TChatLine; var str: shortstring); |
163 procedure RenderChatLineTex(var cl: TChatLine; var str: shortstring); |
164 var strSurface, |
164 var strSurface, tmpSurface, |
165 resSurface: PSDL_Surface; |
165 resSurface: PSDL_Surface; |
166 dstrect : TSDL_Rect; // destination rectangle for blitting |
166 dstrect : TSDL_Rect; // destination rectangle for blitting |
167 font : THWFont; |
167 font : THWFont; |
168 const |
168 const |
169 shadowint = $80 shl AShift; |
169 shadowint = $80 shl AShift; |
192 |
192 |
193 // draw background |
193 // draw background |
194 SDL_FillRect(resSurface, @dstrect, shadowint); |
194 SDL_FillRect(resSurface, @dstrect, shadowint); |
195 |
195 |
196 // create and blit text |
196 // create and blit text |
|
197 tmpSurface:= nil; |
197 strSurface:= TTF_RenderUTF8_Blended(Fontz[font].Handle, Str2PChar(str), cl.color); |
198 strSurface:= TTF_RenderUTF8_Blended(Fontz[font].Handle, Str2PChar(str), cl.color); |
|
199 // fix format |
|
200 if strSurface <> nil then tmpSurface:= SDL_ConvertSurface(strSurface, resSurface^.format, 0); |
|
201 SDL_FreeSurface(strSurface); |
198 //SDL_UpperBlit(strSurface, nil, resSurface, @dstrect); |
202 //SDL_UpperBlit(strSurface, nil, resSurface, @dstrect); |
199 if strSurface <> nil then copyToXY(strSurface, resSurface, Padding, Padding); |
203 if tmpSurface <> nil then copyToXY(tmpSurface, resSurface, Padding, Padding); |
200 SDL_FreeSurface(strSurface); |
204 SDL_FreeSurface(tmpSurface); |
201 |
205 |
202 cl.Tex:= Surface2Tex(resSurface, false); |
206 cl.Tex:= Surface2Tex(resSurface, false); |
203 |
207 |
204 SDL_FreeSurface(resSurface) |
208 SDL_FreeSurface(resSurface) |
205 end; |
209 end; |