编辑:看下面的评论。简短版本:当我尝试运行程序时,屏幕会闪烁。
int main(int argc, char** args)
{
bool quit = false;
std::ofstream out("error.txt");
if(init() == false)
{
return 1;
}
if (load_files() == false)
{
return 1;
}
// Render the text
message = TTF_RenderText_Solid(font, "The quick brown fox jumps over the lazy dog", textColor);
// If there was an error in rendering the text
if (message == NULL)
{
return 1;
}
// Apply the images to the screen
apply_surface(0,0, background, screen);
apply_surface(0,150, message, screen);
// Update the screen
if (SDL_Flip(screen) == -1)
{
std::cout << SDL_GetError() << '\n';
return 1;
}
while (quit == false)
{
while (SDL_PollEvent(&event))
{
if (event.type == SDL_QUIT)
{
quit = true;
}
}
}
clean_up();
return 0;
}
答案 0 :(得分:1)
你遇到的问题是什么?它编译失败了吗?没有链接?由于缺少DLL /共享库而在程序加载时失败?或者在运行时失败?
调用screen
后SDL_SetVideoMode()
是否为空?如果是这样,您应该打印SDL_GetError()
。如果实际上TTF_Init()
失败了,那么打印的错误消息是什么?