high,
sorry for the double “post”. but i just confirmed that my function does
indeed eat up memory. could someone please explain to me what the hell im
doing wrong? i just dont understand. lets say i want to draw the word
"Score:" then next to that i want to draw the score. how the hell do i
update this score without updating the SDL_Surface*??? this is what im
talking about:
first i declare these variables and initialize everything:
//surface for text
SDL_Surface* text;
//font
TTF_Font* font;
TTF_Font* font_big;
//initialize SDL_ttf
TTF_Init();
//open font
font = TTF_OpenFont("arial.ttf",25);
font_big = TTF_OpenFont("arial.ttf",50);
now, i draw the score with this function:
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);
}
now i just call this function whenver i want to draw something. i do this
with Score, Lives, Level, Time. ETC. so this functions getting called
multiple times every frame. i do stuff like this:
Draw_Txt(“Score:”,0,0,1);
//points is a array of characters that stores the players score.
Draw_Txt(points,75,0,1);
i do this with lives,level, ETC. so how come this is bogging down my
computer and hogging all my memory? when i comment out my font drawing,
memory usage goes from 7k to 3k! could someone PLEASE explain to me what im
doing wrong? thanks for any help!!_________________________________________________________________
Check out MSN PC Safety & Security to help ensure your PC is protected and
safe. http://specials.msn.com/msn/security.asp