static void Main(string[] args) { IntPtr win = IntPtr.Zero; IntPtr ren = IntPtr.Zero; SDL.SDL_Event e; uint frameStart; uint frameEnd; uint deltaTimeInMilliseconds = 0; if (!InitSDL(ref win, ref ren)) { DestroySDL(ref win, ref ren); return; } scene.Init(ref ren); bool quit = false; while (!quit) { frameStart = SDL.SDL_GetTicks(); while (SDL.SDL_PollEvent(out e) != 0) { switch (e.type) { case SDL.SDL_EventType.SDL_QUIT: quit = true; break; case SDL.SDL_EventType.SDL_WINDOWEVENT: if (e.window.windowEvent == SDL.SDL_WindowEventID.SDL_WINDOWEVENT_RESIZED) { int newWidth; int newHeight; SDL.SDL_GetWindowSize(win, out newWidth, out newHeight); scene.Resize(newWidth, newHeight); } break; case SDL.SDL_EventType.SDL_KEYDOWN: case SDL.SDL_EventType.SDL_KEYUP: { if (e.key.keysym.sym == SDL.SDL_Keycode.SDLK_q) { quit = true; } else { //Pass event to the scene } } break; case SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN: case SDL.SDL_EventType.SDL_MOUSEBUTTONUP: case SDL.SDL_EventType.SDL_MOUSEMOTION: { //Pass event to the scene } break; default: break; } } SDL.SDL_SetRenderDrawColor(ren, 50, 50, 50, 255); //Set color to BLACK SDL.SDL_RenderClear(ren); //Clear color buffer -> BLACK Update(deltaTimeInMilliseconds); //Using previously computed deltaTimeInMilliseconds -> Variable Frame Rate Game Loop Render(ref ren); frameEnd = SDL.SDL_GetTicks(); deltaTimeInMilliseconds = frameEnd - frameStart; } DestroySDL(ref win, ref ren); }