0

编辑:看下面的评论。简短版:当我尝试运行程序时,屏幕只是闪烁。

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;
}
4

1 回答 1

1

你有什么问题?是不是编译失败?链接失败?由于缺少 DLL/共享库而导致程序加载失败?还是在运行时失败?

screen调用后是NULLSDL_SetVideoMode()吗?如果是这样,您应该打印出SDL_GetError(). 如果实际上TTF_Init()失败了,那么打印的错误消息是什么?

于 2009-09-24T03:34:30.720 回答