Walking Through the Pipeline

When you call cargo run, here is what mirador does:

  1. event_loop and app is initialized, and the app is ran with the event loop. (main.rs) On initialization the app does not have neither a window nor a state. It isn’t until the app is ran with an event loop that it can create a window and a state.

  2. Since the app now has an event loop the first thing it does is call the resumed(&mut self, event_loop: &ActiveEventLoop) method. This method is responsible for initializing the app’s state and creating the window. (app.rs) The initialization of the AppState is where all of the renderer’s, and the game state are initialized.

  3. Now that the app is fully initialized and has a state and a window it awaits the next event from the event loop. After all events in the current frame have been processed it calls self.handle_redraw(); which begins the next frame. On each redraw the wgpu_renderer calls update_canvas(...) which then decides what to render based on the current game state. (i.e. if loading it renders the loading animation, and otherwise it renders the game itself)