# Text surface not applying (SDL)

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

## Recommended Posts

I am attempting to make a player's final score appear onscreen using the following render function.

 void Endgame::render() { SDL_Color textColor = { 0xF0, 0xFF, 0xF0 }; //score int totalScore = 150000 - (rectScore * 1000) - (wallScore * 2000); //render score std::stringstream total; total << "Score: " << totalScore; Score = TTF_RenderText_Solid(font, total.str().c_str(), textColor); //Score is an SDL_Surface included in the class definition. //apply background, score apply_surface(0, 0, background, screen, NULL); apply_surface(50, 100, Score, screen, NULL); //The surface which refuses to apply } 

The program builds and runs to its completion successfully in debug, but I see nothing of the "Score" surface.

Anyone who knows what I am doing wrong feel free to notify me.

##### Share on other sites
You have no error checking. If "Score" is NULL, you should log the result of TTF_GetError() somewhere to see what has gone wrong. The most likely candidate is either not initialising SDL_TTF correctly, or that your font loading failed. Unless you have error checking in these locations either to rule this out?

Also you're going to have a memory leak unless you use SDL_FreeSurface() on the text surface.

##### Share on other sites

The most likely candidate is either not initialising SDL_TTF correctly

OK, yeah, the issue was that I (for whatever reason) commented out the TTF_Init() error check earlier on in the project - which meant it wasn't initializing at all.

Thankyou.

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 11
• 32
• 12
• 12
• 11
• ### Forum Statistics

• Total Topics
631409
• Total Posts
2999929
×