high,
i understand that you should never really load in an image to the same
surface multiple times, or if you do that, you have to Free it as many times
as you loaded it. so whats the deal with SDL_ttf then? you make a
SDL_Surface, and then everytime you draw with it, you re-assign a value to
this surface. is this hogigng up memory and allocating a new surface every
time i draw text (which i do like 5 times each frame)
here is what my Text drawing function looks like:
void Messages::Draw_Txt(char* message,int x,int y,int size)
{
//make it white
SDL_Color color;
color.r = 255;
color.g = 255;
color.b = 255;
//render text if i sent 1 make small text else make big text
if(size == 1)
text = TTF_RenderText_Solid(font,message,color);
else text = TTF_RenderText_Solid(font_big,message,color);
//rectangles
SDL_Rect rcSrc;
SDL_Rect rcDst;
//source rectangle
rcSrc.x = rcSrc.y = 0;
rcSrc.w = text->w;
rcSrc.h = text->h;
//destination rectangle
rcDst = rcSrc;
rcDst.x = x;
rcDst.y = y;
//blit the surface
SDL_BlitSurface(text,&rcSrc,data.screen,&rcDst);
}
text is an SDL_Surface. font and font_big are TTF_Font*'s and initialized
like this:
//open font
font = TTF_OpenFont(“arial.ttf”,25);
font_big = TTF_OpenFont(“arial.ttf”,50);
as you can see, i call this in the function:
if(size == 1)
text = TTF_RenderText_Solid(font,message,color);
else text = TTF_RenderText_Solid(font_big,message,color);
you see how i re-assign a value to text? this happends each time i call this
function, which i call multple times per frame. this means im re-assigning
memory to that SDL_Surface possibly thousands of times? there no way i have
to call SDL_FreeSurface 10000 times, do i? im just a little confused. i
appreciate any help you give me. thanks!_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar ? get it now!
http://toolbar.msn.com/go/onm00200415ave/direct/01/