Hi, I'm working on an SDL program and believe I am having some troubles with scope. Heres my original code, which worked fine and dandy. I've excluded the functions which blatantly are not part of the problem.
So what I wanted to do was change it so SDL_Blitsurface didn't have to be called when the text was changed, so I made ::updateObjectFields() to house it. Here are the two functions that were changed.
1 2 3 4 5 6 7 8 9 10
int createTextObject::updateObjectFields(){
SDL_Rect offset;
for(int fieldIndex=0; fieldIndex> sizeof(textSurface)/sizeof(SDL_Surface*); ++fieldIndex){ //doesnt matter what we use to count because they all same size
offset.x = coords[fieldIndex][0];
offset.y = coords[fieldIndex][1];
if(textSurface[fieldIndex]==NULL){return 1;}
SDL_BlitSurface( textSurface[0], NULL, surfaceDest, &offset );
}
return 0;
}
This function included a loop because I wanted it to blit all the text fields at the same time.
So when I run the code with the modifications, none of the text is blitted at all. This leads me to believe that even though TTF_RenderText_Solid() is returning a pointer, it may be disappearing after the function ends.