在 SDL 2 中重定向输出 [英] Redirecting output in SDL 2
问题描述
我在我的项目中使用 SDL 库并且我正在 Windows 平台上工作.
I'm using the SDL library in my project and I'm working on a Windows platform.
当我决定将我的项目转移到 SDL 2 时,我遇到了一个问题:
When I'd decided to move my project to SDL 2, I encountered a problem:
SDL 1.2 中有一个选项可以通过定义 NO_STDIO_REDIRECT
宏将 stdout/stderr 的输出打印到控制台窗口,而不是打印到文件.但是,我还没有在 SDL 2 中找到那个宏.
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.
有没有办法将 SDL 2 输出打印到控制台而不是标准文件?
Is there a way to print SDL 2 output to the console instead of the standard files?
推荐答案
我怀疑 NO_STDIO_REDIRECT
不再是 SDL2 的一部分.
I suspect that NO_STDIO_REDIRECT
is no longer part of SDL2.
您应该改用 SDL_Log
和所有其他相关函数,用于从您的应用程序中记录消息.
然后你可以使用 SDL_LogSetOutputFunction代码>
到:
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.
这篇关于在 SDL 2 中重定向输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!