Jump to content

  • Log In with Google      Sign In   
  • Create Account


Text surface not applying (SDL)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 A1P4A_0M3GA   Members   -  Reputation: 89

Like
0Likes
Like

Posted 15 May 2011 - 01:36 AM

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.

Thankyou in advance.
-A1P4A 0M3GA
Lead script writer on Scutum [http://www.gamedev.n...-entertainment/]
Team Member of Forcas Entertainment
Amateur programmer with C++ and SDL knowledge
Game Enthusiast

Sponsor:

#2 rip-off   Moderators   -  Reputation: 7622

Like
1Likes
Like

Posted 15 May 2011 - 07:02 AM

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.

#3 A1P4A_0M3GA   Members   -  Reputation: 89

Like
0Likes
Like

Posted 15 May 2011 - 05:19 PM

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.
-A1P4A 0M3GA
Lead script writer on Scutum [http://www.gamedev.n...-entertainment/]
Team Member of Forcas Entertainment
Amateur programmer with C++ and SDL knowledge
Game Enthusiast




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS