• Advertisement
Sign in to follow this  

SDL_Surface Render Limit?

This topic is 3411 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 have a pointer to an SDL_Surface. Every frame, I use TTF_RenderText_Solid() to render the FPS (taken from a stringstream) to that surface. It is blitted to the screen later in my main while loop. After about 250000 frames, the program crashes. Dev-C++'s debug mode tells me that the pointer is pointing to 0x0. After commenting out the line where that SDL_Surface* is blitted, I encountered a similar problem with another SDL_Surface* that serves a similar purpose. Is this because the pointers/surfaces were updated too many times, or is there another problem?

Share this post


Link to post
Share on other sites
Advertisement
Well if a memory location is null then that means that it is being set to null.

I am guessing that you are not specifically setting it to a null so I am guessing that you are writing into an array beyond it's bounds. C arrays don't do bounds checking so if you write to a an index larger than the allocated array then another value next to that array memory will be changed.

Do you have any code you could post? That way we could have a better idea of the trouble spot. I personally haven't had much experience with debugging a problem like that but maybe somebody else could offer some tips.

Share this post


Link to post
Share on other sites
The code where the SDL_Surface*s are set:
std::stringstream fpss, livess;
fpss<<"FPS: "<<fps<<" Frame: "<<frame;
livess<<"x"<<lives;
livesm=TTF_RenderText_Solid(font, livess.str().c_str(), textColor);
fpsm=TTF_RenderText_Solid(font, fpss.str().c_str(), textColor);


Where they are accessed:
apply_surface(screen->w-livesm->w, screen->h-livesm->h, livesm, screen);
apply_surface(0, screen->h-fpsm->h, fpsm, screen);


Each happens every frame.

Share this post


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

  • Advertisement