我的问题是我的 SDL2 窗口正在关闭。
我尝试过调试,但是没有发现任何问题,我认为出了问题,但它并没有引发运行时问题。我迷失了任何可以帮助的东西。我希望我不会浪费你们的时间。
bool keep_window_open = true;
SDL_Surface* win_suf;
std::string input;
SDL_Window* open_window(){
SDL_Init(SDL_INIT_VIDEO);
if(SDL_Init(SDL_INIT_EVERYTHING) < 0)
{
std::cout << "Failed to initialize the SDL2 library\n";
std::terminate();
}
SDL_Window* window = SDL_CreateWindow("cat clicker",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
1000, 500,
0);
return window;
}
SDL_Surface* get_suf(SDL_Window* window){
SDL_Surface* window_surface = SDL_GetWindowSurface(window);
if(!window_surface)
{
std::cout << "Failed to get the surface from the window\n";
std::terminate();
}
return window_surface;
}
int main(int argc, char** argv){
SDL_Window* window = open_window();
while(keep_window_open){
check_if_user_exit_then_exit(window);
SDL_UpdateWindowSurface(window);
}
return 0;
}