流程在 TTF_RenderText_Shaded 行结束
Process ends at TTF_RenderText_Shaded line
我的 SDL 程序包含:
TTF_Init();
TTF_Font *font = TTF_OpenFont("segoeui.ttf",13);
SDL_Color textColor = {0,0,0};
SDL_Color backgroundColor = {34,177,76};
SDL_Surface *myText = TTF_RenderText_Shaded(font,"Some text",textColor,backgroundColor);
当我 运行 来自 Code::Blocks 中的 Build 和 运行 按钮的程序时,没有任何问题,但是当我 运行 来自文件夹的程序时在Windows资源管理器中,window直接打开和关闭,window关闭后,进程不再运行,文件stderr.txt stdout.txt 还在那里。我做了一些测试,发现 SDL_Surface *myText = TTF_RenderText_Shaded(font,"Some text",textColor,backgroundColor);
行似乎结束了进程,就像在任务管理器中按下结束进程按钮一样。
为什么要这样做?我该如何解决?
您应该使用绝对路径而不是相对路径来设置您的字体。如果您打算进行跨平台部署,您可能需要包含类似的内容:
TTF_Font *font;
#ifdef _WIN32
font = TTF_OpenFont("WinPath",13); // The windows path
#elif linux
font = TTF_OpenFont("LinuxPaht",13); // The linux path
#elif MacOS
font = TTF_OpenFont("Mac path",13); // The mac path
#endif
if(font == null)
// Throw an error, return or whatever.
您可以在 Detect Windows or Linux in C, C++
获得准确的指令
我的 SDL 程序包含:
TTF_Init();
TTF_Font *font = TTF_OpenFont("segoeui.ttf",13);
SDL_Color textColor = {0,0,0};
SDL_Color backgroundColor = {34,177,76};
SDL_Surface *myText = TTF_RenderText_Shaded(font,"Some text",textColor,backgroundColor);
当我 运行 来自 Code::Blocks 中的 Build 和 运行 按钮的程序时,没有任何问题,但是当我 运行 来自文件夹的程序时在Windows资源管理器中,window直接打开和关闭,window关闭后,进程不再运行,文件stderr.txt stdout.txt 还在那里。我做了一些测试,发现 SDL_Surface *myText = TTF_RenderText_Shaded(font,"Some text",textColor,backgroundColor);
行似乎结束了进程,就像在任务管理器中按下结束进程按钮一样。
为什么要这样做?我该如何解决?
您应该使用绝对路径而不是相对路径来设置您的字体。如果您打算进行跨平台部署,您可能需要包含类似的内容:
TTF_Font *font;
#ifdef _WIN32
font = TTF_OpenFont("WinPath",13); // The windows path
#elif linux
font = TTF_OpenFont("LinuxPaht",13); // The linux path
#elif MacOS
font = TTF_OpenFont("Mac path",13); // The mac path
#endif
if(font == null)
// Throw an error, return or whatever.
您可以在 Detect Windows or Linux in C, C++
获得准确的指令