Subtitles (by drawing lines from a .txt file?)


#1

I’m very very new to this and what I am trying to do sounds easy enough but I can’t get it right.

What I want: I want to add subtitles to a video sequence I have going on (not worried about synchronization).

What I’m trying to do: I thought the way to go would be to have a .txt file be read and drawn, line by line. I would like for their content to show up, stay for a while and be substituted by the next line from the file, until there are no more lines left.

What is happening: Currently, I can read line by line from a .txt file and either: a) draw the last line, or b) draw all of them on top of each other and it keeps drawing forever.

Code:
I have tried other things but all of it goes wrong and I end up getting to this basic situation I have on the printscreen bellow (seemed like the closest I got to what I want). I also tried moving it to void draw and putting the ofDrawBitmapString after the getline and in this case, it prints all the lines on top of each other and, of course, it keeps drawing forever. I have also tried something with a string array but then it was separating it by words and not lines so I figured that wasn’t a good direction…

Any help? Maybe it is quite obvious but I have no previous experience with openframeworks and c++. Maybe there’s a better way that is not even by reading a file line by line, I don’t know, it doesn’t have to be this way as long as the effect of the end result is the same.

Thanks in advance :slight_smile:


#2

Hi,
did you try using the example loadTextFileExample ?

It really helps load a .txt file into buffers then displays it with a certain speed into the bounding box.

Hope it helps.

P

++


#3

I didn’t know that example, really helped a lot.
Thanks! :slight_smile: