Jump to content
  • Advertisement
Sign in to follow this  
Sylvarant

Strange sdl_ttf print error

This topic is 4065 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm experiencing strange errors with text printing using sdl_ttf when i pass anything to my print function that contains a space in it for example tprint(100,100,"some thing",font,black); it doesn't print it, but when i take away the space like this tprint(100,100,"something",font,black); it does print something ?? very strange. /*----------------------------------------------------------------------------------/ // TPRINT // thoda print function for printing text /----------------------------------------------------------------------------------*/ void tprint(int x, int y,std::string var,TTF_Font* var2,SDL_Color var3) { // render the text SDL_Surface * message = TTF_RenderText_Solid(var2,var.c_str(),var3); // apply the images to the screen apply_surface( x, y, message, screen); } I'm compiling this in Kdevelop in ubuntu 7.04 with all sdl libarys correctly linked

Share this post


Link to post
Share on other sites
Advertisement
I've never had a problem with SDL_ttf and spaces. Tabs and newlines don't work, but spaces have always worked for me. Does it print anything? What does TTF_RenderText return, if it is NULL what is the value of TTF_GetError() return?

BTW, give your function parameters meaningful names. I would write:

void tprint(int x, int y, std::string value, TTF_Font* font, SDL_Color colour);


It is preferable to pass std::string instances by const reference rather than by value, which makes that:

void tprint(int x, int y, const std::string &value, TTF_Font* font, SDL_Color colour);

Share this post


Link to post
Share on other sites
when there's no space in the string it outputs something like 0x80ab3a0
but whenever there's a space in the string it's simply 0

very strange

Share this post


Link to post
Share on other sites
Quote:
Original post by Sylvarant
when there's no space in the string it outputs something like 0x80ab3a0
but whenever there's a space in the string it's simply 0

very strange


What outputs that value, TTF_Render or TTF_GetError?

Try something like this:

void tprint(int x, int y,std::string var,TTF_Font* var2,SDL_Color var3)
{

// render the text
SDL_Surface * message = TTF_RenderText_Solid(var2,var.c_str(),var3);
if( message )
{
// apply the images to the screen
apply_surface( x, y, message, screen);
}
else
{
printf("%s",TTF_GetError());
}
}


Then check the output in stdout.txt.

Share this post


Link to post
Share on other sites
when a string with a space in it is passed to the functions it simply outputs

Text has zero width

it also outputs
Failed loading DPMSDisable: /usr/lib/libX11.so.6: undefined symbol: DPMSDisable
in the very beginning

Share this post


Link to post
Share on other sites
Quote:
Original post by Sylvarant
when a string with a space in it is passed to the functions it simply outputs

Text has zero width

it also outputs
Failed loading DPMSDisable: /usr/lib/libX11.so.6: undefined symbol: DPMSDisable
in the very beginning


Odd. See here too. What version of SDL_ttf are you using? Do you get the same results with the latest version?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!