            try application.display(in: rect)
        }
        
        // sleep to save energy
        let frameDuration = SDL_GetTicks() - startTime
        if frameDuration < frameInterval {
            SDL_Delay(frameInterval - frameDuration)
        }
    }
}

do { try main() }
catch let error as SDLError {
    print("Error: \(error.debugDescription)")