TTF problems
ok for some reason this functoin only prints the first char of the string void Draw_Text(char* FILE_NAME) { TTF_Font *FONT = TTF_OpenFont(FILE_NAME,12); SDL_Color clrFg = {0,0,255,0}; SDL_Surface *sText = TTF_RenderText_Solid( FONT, "Mourier 12", clrFg ); SDL_Rect rcDest = {60,0,0,0}; SDL_BlitSurface(sText,NULL,screen,&rcDest); TTF_CloseFont( FONT ); SDL_FreeSurface( sText ); }; its only called once and this is in sdl is there something im doing wrong here? this IS my first venture into the FFT relm
____________________________"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
"FFT relm". . .lol
I don't really see anything wrong with this code, just making sure you did
TTF_Init();
right?
I don't really see anything wrong with this code, just making sure you did
TTF_Init();
right?
I can't seem to see anything out of the ordinary either. I don't think text would even render or load without having called TTF_Init(), but I guess it might.
Drew Sikora
Executive Producer
GameDev.net
It would run faster if you updated the surface only if the text is different.
Quote:
Original post by Rob Loach
It would run faster if you updated the surface only if the text is different.
MUCH faster :P I can't beleive how horribly slow my engine was until I stopped rendering text every frame. And by rendering/updating Rob and I mean calling the RenderText function. Blitting the rendered surface to the screen is nothing compared to that function. Oh and the higher quality the text the longer the render too (of course)
Drew Sikora
Executive Producer
GameDev.net
SDL_Rect rcDest = {60,0,0,0};
SDL_BlitSurface(sText,NULL,screen,&rcDest);
Am I wrong in thinking that width and hieght need to be set? I guess so if first char prints. But I always try to set them.
w,h are ignored.
Any clipping done?
OOH... how are you upating the screen? flip? updaterect?
Any clipping done?
OOH... how are you upating the screen? flip? updaterect?
Oh, then why have them gesh? Well guess I can cut out some instructions.
Maybe something blank printing over them too?
Maybe something blank printing over them too?
ok well since this thread isnt dead ill tell you what the problem was
THERE WAS NO LOWER CASE DEFINED FOR THE .TTF FILE I WAS USING AND ONLY THE FIRST LETTER WAS CAPATALIZED
also your right i probibly shouldnt render text every fram but how do i get around this because it is called in a function that is called every frame and i dont want a new bool for every text surface i make. If there is a simple way to do this i will do it with all my surfaces im not TOO worried because almost all of the framework for the game is done and it pretty memory efficient (only like 2 megs running) and 50% cpu usage
also in order for that to work i would have to do that with all my surfaces every time one was updated otherwise other images would overlap and hide the ones not updated because they were drawn more recently
THERE WAS NO LOWER CASE DEFINED FOR THE .TTF FILE I WAS USING AND ONLY THE FIRST LETTER WAS CAPATALIZED
also your right i probibly shouldnt render text every fram but how do i get around this because it is called in a function that is called every frame and i dont want a new bool for every text surface i make. If there is a simple way to do this i will do it with all my surfaces im not TOO worried because almost all of the framework for the game is done and it pretty memory efficient (only like 2 megs running) and 50% cpu usage
also in order for that to work i would have to do that with all my surfaces every time one was updated otherwise other images would overlap and hide the ones not updated because they were drawn more recently
____________________________"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement