#include #include int main() { if (SDL_Init(SDL_INIT_VIDEO) < 0) { printf("Failed to initialize the SDL2 library\n"); return -1; } SDL_Window *window = SDL_CreateWindow("SDL2 Window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 680, 480, 0); if (!window) { printf("Failed to create window\n"); return -1; } SDL_Surface *window_surface = SDL_GetWindowSurface(window); if (!window_surface) { printf("Failed to get the surface from the window\n"); return -1; } bool running = true; while (running) { // Create event handling struct SDL_Event input; while (SDL_PollEvent(&input) > 0) { // Handle SDL quit event if (input.type == SDL_QUIT) { running = false; } switch (input.type) { case SDL_QUIT: running = false; case SDL_KEYDOWN: { const Uint8 *keys = SDL_GetKeyboardState(NULL); if (keys[SDL_SCANCODE_ESCAPE]) running = false; } } } } SDL_UpdateWindowSurface(window); }