Hi,
I recently started to learn using SDL, and I encountered a problem and asked
someone about it, and they suggested that I post it here as they thought it
could be a possible bug.
I was playing around and attempting to develop functions for printing text to
a screen immediately and over time (as if the text were being typed). The way
I initially designed it, I made a function with the following definition:
void write_text_instant( int x, int y, SDL_Surface* destination, SDL_Surface*
screen, std::string message, std::string FONT );
This function would open up the font designated in FONT, print the entire
message out on the destination surface at the given ( x, y ) coordinate, and
then close the font file.
I then made a function that had this definition:
void type_text( int x, int y, SDL_Surface* destination, SDL_Surface* screen,
std::string message, std::string FONT );
This function would create a temporary string where I would put the string
message into it character by character, and each time I added a new character,
I would call write_text_instant.
This method was very slow, but it achieved it’s goal. But with the functions
like this, I encountered the problem that is the potential bug. When my text
functions were running, if I clicked on anything other than the window to my
program, it would stop responding. I would have to bring up task manager and
have windows force the program to close.
I’ve changed the write_text_instant function to take an SDL_Font object
instead of opening one everytime, and it runs ten times faster and does not
have this error anymore. Any ideas?
Thanks!
Daniel