Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirecting output in SDL 2

Tags:

sdl

sdl-2

I'm using the SDL library in my project and I'm working on a Windows platform.

When I'd decided to move my project to SDL 2, I encountered a problem:

There was an option in SDL 1.2 to print output from stdout/stderr into the console window, rather than to files by defining a NO_STDIO_REDIRECT macro. However, I haven't found that macro in SDL 2.

Is there a way to print SDL 2 output to the console instead of the standard files?

like image 643
cybermind Avatar asked Mar 22 '23 14:03

cybermind


1 Answers

I suspect that NO_STDIO_REDIRECT is no longer part of SDL2.

You should use instead SDL_Log and all the other related functions to log messages from within your application.
Then you can use SDL_LogSetOutputFunction to:

replace the default log output function with one of your own

Note that you can gracefully handle any given category or priority, being the prototype of the handler the one below:

void SDL_LogOutputFunction(void*           userdata,
                           int             category,
                           SDL_LogPriority priority,
                           const char*     message)

Please, refer to the linked documentation for further details.

like image 78
skypjack Avatar answered May 11 '23 19:05

skypjack