SDL创建窗口有相应的步骤,如下 (1)调用SDL_CreateWindow, (2)创建渲染器SDL_CreateRenderer, (3)显示,调用SDL_RenderPresent,在显示前最好清空之前的显示,调用SDL_RenderClear, 根据上述步骤,编写SDL窗口代码,如下: #include <iostream> #include "SDL.h" using namespace std; int main(int argc, char *argv[]) //main函数必须要有参数 { SDL_Window *pWindow = NULL; SDL_Renderer *pRender = NULL; //1 SDL初始化 SDL_Init(SDL_INIT_VIDEO); // 2 创建窗口 pWindow = SDL_CreateWindow("SDL2 Window", 100, 100, 640, 480, SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS); if (!pWindow) { cout << "window create failed" << endl; SDL_Quit(); return -1; } cout << "Window Create Success" << endl; //3 创建Render