开发者

In SDL do I need to free the surface if I re-render text?

开发者 https://www.devze.com 2023-01-06 13:56 出处:网络
if I use the following code... message = TTF_RenderText_Solid( font, \"Lorem Ipsum\", textColor ); Do I need to free message before I can开发者_JAVA技巧 do this

if I use the following code...

message = TTF_RenderText_Solid( font, "Lorem Ipsum", textColor ); 

Do I need to free message before I can开发者_JAVA技巧 do this

message = TTF_RenderText_Solid( font, "Lorem Ipsum part 2", textColor ); 

i.e. does it give me a new surface (and so I have to clean up the old one) or does it just blit over the old one?


Yes, you should free message with SDL_FreeSurface when you're done with it. The returned SDL_Surface is allocated with SDL_AllocSurface() , and is not reused, so you'll leak if you don't free it in this case.

0

精彩评论

暂无评论...
验证码 换一张
取 消