Hello again all!!! I just have two quick questions...

1.) Is it possible for one to run a program through the "system(command)" and have the output come out on top of an SDL program? Like if I had a background of some sort and typed "system(echo "Hello!")" could I have that output appear ON TOP of the background and not in the terminal itself?

2.) I know it's possible because I've seen it done...but how do you load a text file and display it on top of an SDL window? Like if I had this background(of some sort LOL) and the dialogue was saved in "speech.txt", how would I load that into my program and then display? Is it also possible to change the color, size and font? I know how to actually write on the screen with SDL_ttf, but not from a file.

I'm am doing all of this in Linux by the way and the program runs in fullscreen(hence why no terminal).

Thank you!!

Hello again all!!! I just have two quick questions...

1.) Is it possible for one to run a program through the "system(command)" and have the output come out on top of an SDL program? Like if I had a background of some sort and typed "system(echo "Hello!")" could I have that output appear ON TOP of the background and not in the terminal itself?

Yes, this should be possible but user interaction will be more difficult I think, I have never done this before, but with the system command you just invoke a new shell and run the specified command in it, if I'm not wrong the concept you're looking for is called piping , so use google !!! :) ...

The first method that comes up with me is the following one where a command's/program's output is saved in a file ...

Consider the following problem: you want to display the output of the ls command in your SDL program, then you just add the following command to your program: system("ls>output.txt"); The > lets the shell write the output of the ls-command to a file called 'output.txt', now the only thing left to you is read this file into your SDL Application and display it's contents on the screen :) ...

Hope this helps !

edit:: This is probably not the best method to do this, but it's a simple one which works perfectly if you just want to save a programs output to a file for viewing/displaying it later on ...

Thanks for your quick response! I have heard of piping but I have no idea how to do this. I will look into it. And with your second response, it definitely WOULD work, however, I would like to update the text in "real time" from the output of bash. Plus, I still don't know how to load from a text file in SDL. In google it's all about putting text using SDL_TTF. :-/

Here's a good example for what I'm trying to do:
If I am running the "updatepkg --install-new *.tgz" to update my Slackware system in a C++ program using SDL, How would I go about showing the "/install/slack-desc" file from the package OR showing the actual output from bash on top of a picture background? Piping is one idea, but is there any other ways? Thanks in advance.

>Plus, I still don't know how to load from a text file in SDL
You don't have to use SDL to load the text file, just use the standard C++ file handling routines for this, read a line from the file, put it in a variable and use an SDL function to display it on the screen, is that difficult? NO :) ...

I never even thought about trying that. HAHA!:$ I was so into SDL that I forgot normal c++ commands. Oh well. Thanks tux4life! You've been a really good help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.