【发布时间】:2013-02-28 21:09:34
【问题描述】:
我一直在研究 SDL 和 OpenGL(在 C++ 中),并决定在我的游戏中加入一些文本。
我已经学习了一些教程,但我总是得到同样的错误:“找不到 .ttf”我敢肯定以前有人问过,但是你应该把字体放在哪里,你应该写什么TTF_OpenFont 的第一个参数?这是到目前为止的 TTF 部分。
if (TTF_Init() != 0)
{
cerr << "TTF_Init() Failed: " << TTF_GetError() << endl;
SDL_Quit();
exit(1);
}
TTF_Font *font;
font = TTF_OpenFont("FreeSans.ttf", 24);
if (font == NULL)
{
cerr << "TTF_OpenFont() Failed: " << TTF_GetError() << endl; // <-- This the error report
TTF_Quit();
SDL_Quit();
exit(1);
}
SDL_Surface *text;
SDL_Color text_color = {255, 255, 255};
text = TTF_RenderText_Solid(font, "BLAH, BLAH, BLAH!", text_color);
【问题讨论】:
标签: c++ opengl sdl truetype sdl-ttf