Redirecting output in SDL 2

一曲冷凌霜 提交于 2019-12-10 15:17:43

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/20074939/redirecting-output-in-sdl-2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!