I'm writing GL application that uses external libs, which print errors to the console. I want to catch that and print in the in-game console.
PS: Sorry, for my bad english....
I'm writing GL application that uses external libs, which print errors to the console. I want to catch that and print in the in-game console.
PS: Sorry, for my bad english....
There are two basic approaches you could take to this:
If the libraries all use
std::cout
for the IO you want to capture you can write your ownbasic_streambuf
. You can then just callstd::cout.rdbuf(mybufinst);
to replace the streambuffer, for example using thestd::basic_stringbuf
:You can use a platform specific approach, e.g. on POSIX systems
dup2()
will allow you to replace a file descriptor with another one, or on Windows withSetStdHandle()
. You'd want to use pipes rather than just another file probably and you'd need to be really careful about blocking (so probably want a dedicated thread)